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

Replaced empty th with td #2934

Merged
merged 4 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
30 changes: 24 additions & 6 deletions src/components/table/__snapshots__/table_header_cell.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`align defaults to left 1`] = `
<th
<td
class="euiTableHeaderCell"
role="columnheader"
scope="col"
Expand All @@ -13,11 +13,11 @@ exports[`align defaults to left 1`] = `
class="euiTableCellContent__text"
/>
</div>
</th>
</td>
`;

exports[`align renders center when specified 1`] = `
<th
<td
class="euiTableHeaderCell"
role="columnheader"
scope="col"
Expand All @@ -29,11 +29,11 @@ exports[`align renders center when specified 1`] = `
class="euiTableCellContent__text"
/>
</div>
</th>
</td>
`;

exports[`align renders right when specified 1`] = `
<th
<td
class="euiTableHeaderCell"
role="columnheader"
scope="col"
Expand All @@ -45,7 +45,7 @@ exports[`align renders right when specified 1`] = `
class="euiTableCellContent__text"
/>
</div>
</th>
</td>
`;

exports[`renders EuiTableHeaderCell 1`] = `
Expand All @@ -68,6 +68,24 @@ exports[`renders EuiTableHeaderCell 1`] = `
</th>
`;

exports[`renders td when children is null/undefined 1`] = `
<td
aria-label="aria-label"
class="euiTableHeaderCell testClass1 testClass2"
data-test-subj="test subject string"
role="columnheader"
scope="col"
>
<div
class="euiTableCellContent testClass1 testClass2"
>
<span
class="euiTableCellContent__text"
/>
</div>
</td>
`;

exports[`width and style accepts style attribute 1`] = `
<th
class="euiTableHeaderCell"
Expand Down
6 changes: 6 additions & 0 deletions src/components/table/table_header_cell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ test('renders EuiTableHeaderCell', () => {
expect(render(component)).toMatchSnapshot();
});

test('renders td when children is null/undefined', () => {
const component = render(<EuiTableHeaderCell {...requiredProps} />);

expect(component).toMatchSnapshot();
});

describe('align', () => {
test('defaults to left', () => {
const component = <EuiTableHeaderCell />;
Expand Down
10 changes: 6 additions & 4 deletions src/components/table/table_header_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ export const EuiTableHeaderCell: FunctionComponent<Props> = ({

const styleObj = resolveWidthAsStyle(style, width);

const CellComponent = children ? 'th' : 'td';

if (onSort) {
const buttonClasses = classNames('euiTableHeaderButton', {
'euiTableHeaderButton-isSorted': isSorted,
Expand All @@ -114,7 +116,7 @@ export const EuiTableHeaderCell: FunctionComponent<Props> = ({
}

return (
<th
<CellComponent
className={classes}
scope={scope}
role="columnheader"
Expand Down Expand Up @@ -142,12 +144,12 @@ export const EuiTableHeaderCell: FunctionComponent<Props> = ({
</EuiScreenReaderOnly>
</span>
</button>
</th>
</CellComponent>
);
}

return (
<th
<CellComponent
className={classes}
scope={scope}
role="columnheader"
Expand All @@ -156,6 +158,6 @@ export const EuiTableHeaderCell: FunctionComponent<Props> = ({
<div className={contentClasses}>
<span className="euiTableCellContent__text">{children}</span>
</div>
</th>
</CellComponent>
);
};