Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(DataTable): align items top on text wrapping #13525

Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
368c8b5
fix(DataTable): align items top on text wrapping
francinelucca Apr 13, 2023
9f176db
fix(Table): yarn format
francinelucca Apr 14, 2023
3db2f75
Merge branch 'main' of github.com:carbon-design-system/carbon into 12…
francinelucca Apr 14, 2023
d9e607e
chore: add canvas as a dev dependency
francinelucca Apr 14, 2023
0033bf1
fix(TableHeader): correct sorting padding
francinelucca Apr 14, 2023
7aaf4f1
fix(TableHeader): yarn format
francinelucca Apr 14, 2023
ff4543b
fix: run dedupe
francinelucca Apr 14, 2023
77295cf
Merge branch 'main' of github.com:carbon-design-system/carbon into 12…
francinelucca Apr 27, 2023
8e3a3cf
test(DataTable): performance testing on new autoAlign property
francinelucca May 1, 2023
991ac65
Merge branch 'main' of github.com:carbon-design-system/carbon into 12…
francinelucca May 15, 2023
eb46f73
Merge branch 'main' of github.com:carbon-design-system/carbon into 12…
francinelucca May 16, 2023
e5aa430
test(DataTable): add table,cell, and row autoAlign test stories
francinelucca May 16, 2023
dec157d
fix: format
francinelucca May 16, 2023
668b0d5
fix(DataTable): refacotr autoAlign logic to live in Table
francinelucca May 17, 2023
1caa369
fix: format
francinelucca May 17, 2023
3cab071
fix(TableRow): remove whitespace
francinelucca May 17, 2023
91a75be
fix(DataTable): add autoAlign docs and tests
francinelucca May 17, 2023
7f0d4be
Merge branch 'main' of github.com:carbon-design-system/carbon into 12…
francinelucca May 17, 2023
f6918a9
fix(Table): replace useEvent with useWindowEvent
francinelucca May 17, 2023
b8c6c29
test: update snapshot
francinelucca May 18, 2023
ad462d8
Merge branch 'main' of github.com:carbon-design-system/carbon into 12…
francinelucca May 18, 2023
1363cde
fix(DataTable): use lodash.debounce for autoAlign feature
francinelucca May 18, 2023
bc103f3
Merge branch 'main' of github.com:carbon-design-system/carbon into 12…
francinelucca May 22, 2023
af5bc55
fix(DataTable): do not align header top on autoAlign
francinelucca May 22, 2023
5e36daa
fix(DataTable): align expand button to top on md size when autoAlign
francinelucca May 22, 2023
57cbac1
fix(DataTable): align checkbox top on autoAlign wrappring
francinelucca May 22, 2023
c20f7c5
fix(DataTable): align radioButton top on autoAlign wrapping
francinelucca May 22, 2023
445e0a3
fix(DataTable): align overflowmenu top on datatable autoAlign wrapping
francinelucca May 22, 2023
66d9fe7
fix(DataTable): offset checkbox top padding in lg autoAlign wrapping
francinelucca May 22, 2023
64bc26a
Merge branch 'main' of github.com:carbon-design-system/carbon into 12…
francinelucca May 24, 2023
f7cdc0b
fix(DataTable): add table header align logic and css
francinelucca May 25, 2023
76c8ecf
fix(DataTable): add tests for header auto alignment
francinelucca May 26, 2023
d1465d4
fix: format
francinelucca May 26, 2023
4a23248
Merge branch 'main' of github.com:carbon-design-system/carbon into 12…
francinelucca May 31, 2023
5f63517
fix(DataTable): top alignment expansion css fixes
francinelucca May 31, 2023
dab3c57
Merge branch 'main' into 12610-bug-data-table-content-inside-cells-sh…
francinelucca Jun 1, 2023
d14475f
Merge branch 'main' into 12610-bug-data-table-content-inside-cells-sh…
kodiakhq[bot] Jun 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,9 @@ Map {
"className": Object {
"type": "string",
},
"experimentalAutoAlign": Object {
"type": "bool",
},
"isSortable": Object {
"type": "bool",
},
Expand Down Expand Up @@ -2259,6 +2262,9 @@ Map {
"translateWithId": [Function],
},
"propTypes": Object {
"experimentalAutoAlign": Object {
"type": "bool",
},
"filterRows": Object {
"type": "func",
},
Expand Down Expand Up @@ -7314,6 +7320,9 @@ Map {
"className": Object {
"type": "string",
},
"experimentalAutoAlign": Object {
"type": "bool",
},
"isSortable": Object {
"type": "bool",
},
Expand Down
1 change: 1 addition & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"babel-preset-carbon": "^0.5.0",
"browserify-zlib": "^0.2.0",
"browserslist-config-carbon": "^11.2.0",
"canvas": "^2.11.2",
tay1orjones marked this conversation as resolved.
Show resolved Hide resolved
"clipboardy": "^2.1.0",
"css-loader": "^6.5.1",
"enquirer": "^2.3.6",
Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/components/DataTable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ const translateWithId = (id) => defaultTranslations[id];
*/
class DataTable extends React.Component {
static propTypes = {
/**
* Experimental property. Allows table to align cell contents to the top if there is text wrapping in the content. Might have performance issues, intended for smaller tables
*/
experimentalAutoAlign: PropTypes.bool,

/**
* Optional hook to manually control filtering of the rows from the
* TableToolbarSearch component
Expand Down Expand Up @@ -416,6 +421,7 @@ class DataTable extends React.Component {
useStaticWidth,
stickyHeader,
overflowMenuOnHover,
experimentalAutoAlign,
} = this.props;
return {
useZebraStyles,
Expand All @@ -424,6 +430,7 @@ class DataTable extends React.Component {
useStaticWidth,
stickyHeader,
overflowMenuOnHover,
experimentalAutoAlign,
};
};

Expand Down
124 changes: 122 additions & 2 deletions packages/react/src/components/DataTable/DataTable.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Story, Props, Source, Preview } from '@storybook/addon-docs';
import { Table, TableHead, TableHeader, TableRow, TableCell, TableBody } from '../DataTable'

# DataTable

Expand All @@ -14,7 +15,6 @@ import { Story, Props, Source, Preview } from '@storybook/addon-docs';

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

## Table of Contents

- [Getting started](#getting-started)
Expand All @@ -24,9 +24,14 @@ import { Story, Props, Source, Preview } from '@storybook/addon-docs';
- [Expansion](#expansion)
- [Programmatic expansion](#programmatic-expansion)
- [Selection](#selection)
- [Programmatic selection](#programmatic-selection)
- [Programmatic selection](#programmatic-selection)
- [Filtering](#filtering)
- [Batch actions](#batch-actions)
- [Toolbar](#toolbar)
- [Overflow Menu](#overflow-menu)
- [Text Wrapping Alignment](#text-wrapping-alignment)
- [Table with `experimentalAutoAlign = true`](#table-with-experimentalautoalign--true)
- [Table with `experimentalAutoAlign = false`](#table-with-experimentalautoalign--false)
- [Props](#props)
- [Render props](#render-props)
- [Prop getters](#prop-getters)
Expand Down Expand Up @@ -314,6 +319,121 @@ cell.
</TableBody>
```

## Text Wrapping Alignment

DataTable provides an experimental `experimentalAutoAlign` prop that you may
opt into to have the table automatically align contents to the top when at least
one table cell content is being wrapped on the table. Keep in mind this feature
is experimental and might not be performant in tables with large datasets.

### Table with `experimentalAutoAlign = true`

<div style={{width: '300px'}}>
<Table experimentalAutoAlign>
<TableHead>
<TableRow>
<TableHeader>
Header1
</TableHeader>
<TableHeader>
Header2
</TableHeader>
<TableHeader>
Header3
</TableHeader>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell>Wrapping content</TableCell>
<TableCell>content</TableCell>
<TableCell>content</TableCell>
</TableRow>
</TableBody>
</Table>
</div>

```jsx
<div style={{width: '300px'}}>
<Table experimentalAutoAlign>
<TableHead>
<TableRow>
<TableHeader>
Header1
</TableHeader>
<TableHeader>
Header2
</TableHeader>
<TableHeader>
Header3
</TableHeader>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell>Wrapping content</TableCell>
<TableCell>content</TableCell>
<TableCell>content</TableCell>
</TableRow>
</TableBody>
</Table>
</div>
```

### Table with `experimentalAutoAlign = false`

<div style={{width: '300px'}}>
<Table>
<TableHead>
<TableRow>
<TableHeader>
Header1
</TableHeader>
<TableHeader>
Header2
</TableHeader>
<TableHeader>
Header3
</TableHeader>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell>Wrapping content</TableCell>
<TableCell>content</TableCell>
<TableCell>content</TableCell>
</TableRow>
</TableBody>
</Table>
</div>

```jsx
<div style={{width: '300px'}}>
<Table>
<TableHead>
<TableRow>
<TableHeader>
Header1
</TableHeader>
<TableHeader>
Header2
</TableHeader>
<TableHeader>
Header3
</TableHeader>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell>Wrapping content</TableCell>
<TableCell>content</TableCell>
<TableCell>content</TableCell>
</TableRow>
</TableBody>
</Table>
</div>
```

## Props

<Props />
Expand Down
Loading