diff --git a/packages/@adobe/spectrum-css-temp/components/table/index.css b/packages/@adobe/spectrum-css-temp/components/table/index.css index 6219f2a10fc..bec5a67260c 100644 --- a/packages/@adobe/spectrum-css-temp/components/table/index.css +++ b/packages/@adobe/spectrum-css-temp/components/table/index.css @@ -157,6 +157,10 @@ governing permissions and limitations under the License. } .spectrum-Table-cellContents { + flex: 1 1 0%; + /* To ensure the flex child only takes up available width, see https://makandracards.com/makandra/66994-css-flex-and-min-width */ + min-width: 0px; + /* truncate text with ellipsis */ overflow: hidden; white-space: nowrap; diff --git a/packages/@react-spectrum/table/src/TableView.tsx b/packages/@react-spectrum/table/src/TableView.tsx index 97d14c2eb9a..3428a37c9d3 100644 --- a/packages/@react-spectrum/table/src/TableView.tsx +++ b/packages/@react-spectrum/table/src/TableView.tsx @@ -626,6 +626,7 @@ function TableCell({cell}) { stylesOverrides, 'react-spectrum-Table-cell', { + 'react-spectrum-Table-cell--alignStart': columnProps.align === 'start', 'react-spectrum-Table-cell--alignCenter': columnProps.align === 'center', 'react-spectrum-Table-cell--alignEnd': columnProps.align === 'end' } diff --git a/packages/@react-spectrum/table/src/table.css b/packages/@react-spectrum/table/src/table.css index 07a75db8fb1..8590918067c 100644 --- a/packages/@react-spectrum/table/src/table.css +++ b/packages/@react-spectrum/table/src/table.css @@ -27,11 +27,18 @@ height: 100%; } +.react-spectrum-Table-cell--alignStart { + text-align: start; + justify-content: start; +} + .react-spectrum-Table-cell--alignCenter { + text-align: center; justify-content: center; } .react-spectrum-Table-cell--alignEnd { + text-align: end; justify-content: flex-end; } diff --git a/packages/@react-spectrum/table/stories/Table.stories.tsx b/packages/@react-spectrum/table/stories/Table.stories.tsx index 855b5b37d16..af1ba723b2d 100644 --- a/packages/@react-spectrum/table/stories/Table.stories.tsx +++ b/packages/@react-spectrum/table/stories/Table.stories.tsx @@ -380,6 +380,115 @@ storiesOf('TableView', module) ), {chromatic: {disable: true}} ) + .add( + 'should fill cell width', + () => ( + onSelectionChange([...s])}> + + File Name + Type + Size + Description + + + + 2018 Proposal + PDF + 214 KB + very very very very very very long long long long long description + + + + + 100% + + + + + 100% + + + + + 100% + + + + + very very very very very very long long long long long description + + + + + + + 50% div + + + + + 70% div + + + + + 70% div + + + + + very very very very very very long long long long long description + + + + + + + span child + + + + + span child + + + + span child + + + + + very very very very very very long long long long long description + + + + + + ) + ) .add( 'column widths and dividers', () => (