diff --git a/CHANGELOG.md b/CHANGELOG.md index 42fa46c13c3..a90f17e11da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) +- Empty table th elements replaced with td in `EuiTable`. ([#2934](https://github.com/elastic/eui/pull/2934)) - Added default prompt text to `aria-describedby` for `EuiFilePicker` ([#2919](https://github.com/elastic/eui/pull/2919)) - Added SASS variables for text variants of the primary palette `$euiColorPrimaryText`, `$euiColorSecondaryText`, etc... Updated components to use these new variables. ([#2873](https://github.com/elastic/eui/pull/2873)) - Updated SASS mixin `makeHighContrastColor()` to default `$background: $euiPageBackgroundColor` and `$ratio: 4.5`. Created `makeGraphicContrastColor()` for graphic specific contrast levels of 3.0. ([#2873](https://github.com/elastic/eui/pull/2873)) diff --git a/src/components/table/__snapshots__/table_header_cell.test.tsx.snap b/src/components/table/__snapshots__/table_header_cell.test.tsx.snap index b6a4321e000..abbec8cae31 100644 --- a/src/components/table/__snapshots__/table_header_cell.test.tsx.snap +++ b/src/components/table/__snapshots__/table_header_cell.test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`align defaults to left 1`] = ` - - + `; exports[`align renders center when specified 1`] = ` - - + `; exports[`align renders right when specified 1`] = ` - - + `; exports[`renders EuiTableHeaderCell 1`] = ` @@ -68,6 +68,24 @@ exports[`renders EuiTableHeaderCell 1`] = ` `; +exports[`renders td when children is null/undefined 1`] = ` + +
+ +
+ +`; + exports[`width and style accepts style attribute 1`] = ` { expect(render(component)).toMatchSnapshot(); }); +test('renders td when children is null/undefined', () => { + const component = render(); + + expect(component).toMatchSnapshot(); +}); + describe('align', () => { test('defaults to left', () => { const component = ; diff --git a/src/components/table/table_header_cell.tsx b/src/components/table/table_header_cell.tsx index b0c8406e20b..db0e2dcdb88 100644 --- a/src/components/table/table_header_cell.tsx +++ b/src/components/table/table_header_cell.tsx @@ -91,6 +91,8 @@ export const EuiTableHeaderCell: FunctionComponent = ({ const styleObj = resolveWidthAsStyle(style, width); + const CellComponent = children ? 'th' : 'td'; + if (onSort) { const buttonClasses = classNames('euiTableHeaderButton', { 'euiTableHeaderButton-isSorted': isSorted, @@ -114,7 +116,7 @@ export const EuiTableHeaderCell: FunctionComponent = ({ } return ( - = ({ - + ); } return ( - = ({
{children}
- + ); };