Skip to content
Merged
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
64 changes: 45 additions & 19 deletions src/components/table/table_header_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
RIGHT_ALIGNMENT,
CENTER_ALIGNMENT,
} from '../../services';
import { EuiI18n } from '../i18n';

export type TableHeaderCellScope = 'col' | 'row' | 'colgroup' | 'rowgroup';

Expand Down Expand Up @@ -106,14 +107,29 @@ export const EuiTableHeaderCell: FunctionComponent<Props> = ({

function getScreenCasterDirection() {
if (ariaSortValue === 'ascending') {
return 'Click to sort in descending order';
return (
<EuiI18n
token="euiTableHeaderCell.clickForDescending"
default="Click to sort in descending order"
/>
);
}

if (allowNeutralSort && ariaSortValue === 'descending') {
return 'Click to unsort';
return (
<EuiI18n
token="euiTableHeaderCell.clickForUnsort"
default="Click to unsort"
/>
);
}

return 'Click to sort in ascending order';
return (
<EuiI18n
token="euiTableHeaderCell.clickForAscending"
default="Click to sort in ascending order"
/>
);
}

return (
Expand All @@ -133,26 +149,36 @@ export const EuiTableHeaderCell: FunctionComponent<Props> = ({
<span className={contentClasses}>
<EuiInnerText>
{(ref, innerText) => (
<span
title={
isSorted
? `${innerText} sorted in ${ariaSortValue} order`
: innerText
}
ref={ref}
className="euiTableCellContent__text">
{children}
</span>
<EuiI18n
token="euiTableHeaderCell.titleTextWithSort"
default="{innerText}; Sorted in {ariaSortValue} order"
values={{ innerText, ariaSortValue }}>
{(titleTextWithSort: string) => (
<span
title={isSorted ? titleTextWithSort : innerText}
ref={ref}
className="euiTableCellContent__text">
{children}
</span>
)}
</EuiI18n>
)}
</EuiInnerText>

{isSorted && (
<EuiIcon
className="euiTableSortIcon"
type={isSortAscending ? 'sortUp' : 'sortDown'}
size="m"
aria-label={`Sorted in ${ariaSortValue} order`}
/>
<EuiI18n
token="euiTableHeaderCell.sortedAriaLabel"
default="Sorted in {ariaSortValue} order"
values={{ ariaSortValue }}>
{(sortedAriaLabel: string) => (
<EuiIcon
className="euiTableSortIcon"
type={isSortAscending ? 'sortUp' : 'sortDown'}
size="m"
aria-label={sortedAriaLabel}
/>
)}
</EuiI18n>
)}
<EuiScreenReaderOnly>
<span>{getScreenCasterDirection()}</span>
Expand Down