Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
[terra-table] Add missing ID to header cells. (#3336)
Browse files Browse the repository at this point in the history
* Add missing ID to header cells.

* Updated tests with unique IDs

Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
  • Loading branch information
dkasper-was-taken and mjhenkes authored Jan 29, 2021
1 parent 0d0d3b6 commit d4ebaad
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
3 changes: 3 additions & 0 deletions packages/terra-table/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Fixed
* Fixed missing id mapping for header cells

## 4.20.0 - (January 5, 2021)

* Changed
Expand Down
1 change: 1 addition & 0 deletions packages/terra-table/src/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ const createHeader = (tableData) => {
{tableData.headerData.cells.map((cellData, colIndex) => (
<HeaderCell
{...cellData.attrs}
id={cellData.id}
key={cellData.key}
refCallback={cellData.refCallback}
metaData={cellData.metaData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ const CustomCell = () => (
headerData={{
cells: [
{
id: 'header-name',
id: 'header-name-1',
key: 'name0',
children: 'Column 0',
},
{
id: 'header-name',
id: 'header-name-2',
key: 'name1',
children: 'Column 1',
},
{
id: 'header-name',
id: 'header-name-3',
key: 'name2',
children: 'Column 2',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const HeaderCheckMarkTest = () => (
numberOfColumns={1}
headerData={{
selectAllColumn: { checkLabel: 'Column Example Title' },
cells: [{ id: 'column-0', key: 'key-0', children: 'Default' }],
cells: [{ id: 'example-column-0', key: 'key-0', children: 'Default' }],
}}
/>
<Table
Expand All @@ -21,7 +21,7 @@ const HeaderCheckMarkTest = () => (
numberOfColumns={1}
headerData={{
selectAllColumn: { checkLabel: 'Column Example Title', onCheckAction: () => {}, checkStatus: 'empty' },
cells: [{ id: 'column-0', key: 'key-0', children: 'Selectable Unchecked' }],
cells: [{ id: 'empty-column-0', key: 'key-0', children: 'Selectable Unchecked' }],
}}
/>
<Table
Expand All @@ -31,7 +31,7 @@ const HeaderCheckMarkTest = () => (
numberOfColumns={1}
headerData={{
selectAllColumn: { checkLabel: 'Column Example Title', onCheckAction: () => {}, checkStatus: 'checked' },
cells: [{ id: 'column-0', key: 'key-0', children: 'Selectable Checked' }],
cells: [{ id: 'checked-column-0', key: 'key-0', children: 'Selectable Checked' }],
}}
/>
<Table
Expand All @@ -41,7 +41,7 @@ const HeaderCheckMarkTest = () => (
numberOfColumns={1}
headerData={{
selectAllColumn: { checkLabel: 'Column Example Title', onCheckAction: () => {}, checkStatus: 'indeterminate' },
cells: [{ id: 'column-0', key: 'key-0', children: 'Selectable Indeterminate' }],
cells: [{ id: 'indeterminate-column-0', key: 'key-0', children: 'Selectable Indeterminate' }],
}}
/>
<Table
Expand All @@ -51,7 +51,7 @@ const HeaderCheckMarkTest = () => (
numberOfColumns={1}
headerData={{
selectAllColumn: { checkLabel: 'Column Example Title', onCheckAction: () => {}, isDisabled: true },
cells: [{ id: 'column-0', key: 'key-0', children: 'Disabled' }],
cells: [{ id: 'disabled-column-0', key: 'key-0', children: 'Disabled' }],
}}
/>
<Table
Expand All @@ -61,7 +61,7 @@ const HeaderCheckMarkTest = () => (
numberOfColumns={1}
headerData={{
selectAllColumn: { checkLabel: 'Column Example Title', onCheckAction: () => {}, checkAlignment: '1rem' },
cells: [{ id: 'column-0', key: 'key-0', children: 'Vertical Alignment 1rem' }],
cells: [{ id: 'alignment-column-0', key: 'key-0', children: 'Vertical Alignment 1rem' }],
}}
/>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PaddingTable = () => (
numberOfColumns={1}
headerData={{
cells: [
{ id: 'header-name', key: 'name', children: 'Name' },
{ id: 'compact-header-name', key: 'name', children: 'Name' },
],
}}
bodyData={[
Expand All @@ -33,7 +33,7 @@ const PaddingTable = () => (
numberOfColumns={1}
headerData={{
cells: [
{ id: 'header-name', key: 'name', children: 'Name' },
{ id: 'standard-header-name', key: 'name', children: 'Name' },
],
}}
bodyData={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ exports[`Table should render a Table with check style icon and row style toggle
label="test-label"
/>
<HeaderCell
id="cell-id"
isSortActive={false}
isSortDesc={false}
key="cell-key"
Expand Down Expand Up @@ -168,6 +169,7 @@ exports[`Table should render a Table with check style toggle 1`] = `
label="test-label"
/>
<HeaderCell
id="cell-id"
isSortActive={false}
isSortDesc={false}
key="cell-key"
Expand Down Expand Up @@ -231,6 +233,7 @@ exports[`Table should render a Table with check style toggle and row style discl
label="test-label"
/>
<HeaderCell
id="cell-id"
isSortActive={false}
isSortDesc={false}
key="cell-key"
Expand Down Expand Up @@ -398,6 +401,7 @@ exports[`Table should render a Table with header 1`] = `
aria-rowindex={1}
>
<HeaderCell
id="cell-id"
isSortActive={false}
isSortDesc={false}
key="cell-key"
Expand All @@ -424,6 +428,7 @@ exports[`Table should render a Table with header with chevrons 1`] = `
aria-rowindex={1}
>
<HeaderCell
id="cell-id"
isSortActive={false}
isSortDesc={false}
key="cell-key"
Expand Down Expand Up @@ -485,6 +490,7 @@ exports[`Table should render a Table with inners remove despite padding 1`] = `
aria-rowindex={1}
>
<HeaderCell
id="cell-id"
isSortActive={false}
isSortDesc={false}
key="cell-key"
Expand Down Expand Up @@ -620,6 +626,7 @@ exports[`Table should render a Table with row style toggle 1`] = `
label="test-label"
/>
<HeaderCell
id="cell-id"
isSortActive={false}
isSortDesc={false}
key="cell-key"
Expand Down Expand Up @@ -842,6 +849,7 @@ exports[`Table should render a Table with widths 1`] = `
aria-rowindex={1}
>
<HeaderCell
id="cell-id"
isSortActive={false}
isSortDesc={false}
key="cell-key"
Expand Down

0 comments on commit d4ebaad

Please sign in to comment.