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

[Emotion] Convert final EuiDataGrid cell styles (Part 5) #8013

Merged
merged 28 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
175b2f8
Convert remaining `.euiDataGridRowCell` styles
cee-chen Sep 10, 2024
046bfef
Convert remaining `.euiDataGridRowCell__content` styles
cee-chen Sep 10, 2024
ba408b6
Update downstream snapshots
cee-chen Sep 9, 2024
91a349c
Convert remaining `.euiDataGridHeaderCell` styles
cee-chen Sep 10, 2024
89ad354
[refactor] Remove unnecessary `CellContent` FC
cee-chen Sep 10, 2024
45aeb31
Convert `.euiDataGridHeaderCell__content` styles
cee-chen Sep 10, 2024
95548bb
[refactor] Clean up column actions button/icon DOM+CSS
cee-chen Sep 10, 2024
ccde288
Convert `.euiDataGridHeaderCell__button` styles
cee-chen Sep 10, 2024
c9327ca
Add VRT/E2E tests for header styles
cee-chen Sep 10, 2024
8320712
[refactor] clean up header control column DOM
cee-chen Sep 10, 2024
25d92ff
Update downstream tests/snapshots
cee-chen Sep 10, 2024
480f098
[Enhancement] Replace unused header cell actions CSS
cee-chen Sep 1, 2024
22f27c8
Convert column resizer styles
cee-chen Sep 1, 2024
18ce982
Convert remaining `.euiDataGridFooterCell` styles
cee-chen Sep 9, 2024
2a80790
changelog
cee-chen Sep 10, 2024
64d3ce5
Delete all data grid Sass files
cee-chen Sep 1, 2024
9e68f6f
Final component Sass deletions 🥲
cee-chen Sep 10, 2024
d70c124
[tech debt] Address various Emotion component post-conversion TODOs
cee-chen Sep 10, 2024
5d47175
Final EuiDataGrid VRT updates
cee-chen Sep 10, 2024
d7d70c2
Fix Storybook control docgen for `gridStyle`/`rowHeightsOptions`/`too…
cee-chen Sep 10, 2024
456f5ef
Fix Cypress axe test
cee-chen Sep 10, 2024
64f1748
[PR feedback] Fix column actions button sizing
cee-chen Sep 11, 2024
fb0178c
[PR feedback] Remove `export` on internal consts
cee-chen Sep 11, 2024
3e6c32b
[refactor] avoid render prop + unmemoized array by creating a new fun…
cee-chen Sep 11, 2024
7594ac8
[a11y] Fix VO not correctly reading out SR text due to newlines in JSX
cee-chen Sep 11, 2024
bf7853e
[refactor] remove non-content children out of EuiDataGridCellContent
cee-chen Sep 11, 2024
f53c710
[cleanup] Replace `hidden` attribute with conditional JSX
cee-chen Sep 12, 2024
0b29898
[refactor] clean up focus trap aria-describedby text
cee-chen Sep 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,8 @@ describe('FocusTrappedChildren', () => {
data-focus-lock-disabled="disabled"
>
<p
aria-hidden="true"
class="emotion-euiScreenReaderOnly"
id="euiDataGridCellHeader_generated-id_exited"
/>
<p
aria-hidden="true"
class="emotion-euiScreenReaderOnly"
id="euiDataGridCellHeader_generated-id_keyboardHint"
hidden=""
id="generated-id_focusTrapHint"
>
Press the Enter key to interact with this cell's contents.
</p>
Expand Down
82 changes: 38 additions & 44 deletions packages/eui/src/components/datagrid/body/cell/focus_utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import React, {
import { FocusableElement, tabbable } from 'tabbable';
import classNames from 'classnames';

import { keys } from '../../../../services';
import { useGeneratedHtmlId } from '../../../../services/accessibility';
import { keys, useGeneratedHtmlId } from '../../../../services';
import { isDOMNode } from '../../../../utils';
import { EuiFocusTrap } from '../../../focus_trap';
import { EuiScreenReaderOnly } from '../../../accessibility';
import { EuiI18n } from '../../../i18n';

/**
Expand Down Expand Up @@ -92,14 +90,8 @@ export const FocusTrappedChildren: FunctionComponent<
const [isCellEntered, setIsCellEntered] = useState(false);
const [isExited, setExited] = useState(false);

const keyboardHintAriaId = useGeneratedHtmlId({
prefix: 'euiDataGridCellHeader',
suffix: 'keyboardHint',
});

const exitedHintAriaId = useGeneratedHtmlId({
prefix: 'euiDataGridCellHeader',
suffix: 'exited',
const ariaDescribedById = useGeneratedHtmlId({
suffix: 'focusTrapHint',
});

// direct DOM manipulation as workaround to attach required hints
Expand All @@ -108,9 +100,17 @@ export const FocusTrappedChildren: FunctionComponent<

cellEl.setAttribute(
'aria-describedby',
classNames(currentAriaDescribedbyId, exitedHintAriaId, keyboardHintAriaId)
classNames(currentAriaDescribedbyId, ariaDescribedById)
);
}, [cellEl, keyboardHintAriaId, exitedHintAriaId]);

return () => {
if (currentAriaDescribedbyId) {
cellEl.setAttribute('aria-descibedby', currentAriaDescribedbyId);
} else {
cellEl.removeAttribute('aria-describedby');
}
};
}, [cellEl, ariaDescribedById]);

useEffect(() => {
if (isCellEntered) {
Expand Down Expand Up @@ -173,37 +173,31 @@ export const FocusTrappedChildren: FunctionComponent<
>
{children}

<EuiScreenReaderOnly>
{/**
* Hints use aria-hidden to prevent them from being read as regular content.
* They are still read in JAWS and NVDA via the linking with aria-describedby.
* VoiceOver does generally not read the column on re-focus after exiting a cell,
* which mean the exited hint is not read.
* VoiceOver does react to aria-live (without aria-hidden) but that would causes
* duplicate output in JAWS/NVDA (reading content & live announcement).
* Optimizing for Windows screen readers as they have a larger usages.
*/}
<p id={exitedHintAriaId} aria-hidden="true">
{isExited && (
<EuiI18n
// eslint-disable-next-line local/i18n
token="euiDataGridCell.focusTrapExitPrompt"
default="Exited cell content."
/>
)}
</p>
</EuiScreenReaderOnly>
<EuiScreenReaderOnly>
<p id={keyboardHintAriaId} aria-hidden="true">
{!isCellEntered && (
<EuiI18n
// eslint-disable-next-line local/i18n
token="euiDataGridCell.focusTrapEnterPrompt"
default="Press the Enter key to interact with this cell's contents."
/>
)}
</p>
</EuiScreenReaderOnly>
{/**
* Hints use `hidden` to prevent them from being read by screen readers as regular content.
* They are still read in JAWS and NVDA via the linking with aria-describedby.
* VoiceOver does generally not read the column on re-focus after exiting a cell,
* which mean the exited hint is not read.
* VoiceOver does react to aria-live (without aria-hidden) but that would causes
* duplicate output in JAWS/NVDA (reading content & live announcement).
* Optimizing for Windows screen readers as they have a larger usages.
*/}
<p id={ariaDescribedById} hidden>
mgadewoll marked this conversation as resolved.
Show resolved Hide resolved
{isExited && (
<EuiI18n
// eslint-disable-next-line local/i18n
token="euiDataGridCell.focusTrapExitPrompt"
default="Exited cell content."
/>
)}
{!isCellEntered && (
<EuiI18n
// eslint-disable-next-line local/i18n
token="euiDataGridCell.focusTrapEnterPrompt"
default="Press the Enter key to interact with this cell's contents."
/>
)}
</p>
</EuiFocusTrap>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('EuiDataGridControlHeaderCell', () => {
const { container } = render(<EuiDataGridControlHeaderCell {...props} />);
expect(container.firstChild).toMatchInlineSnapshot(`
<div
aria-describedby="euiDataGridCellHeader_generated-id_exited euiDataGridCellHeader_generated-id_keyboardHint"
aria-describedby="generated-id_focusTrapHint"
class="euiDataGridHeaderCell euiDataGridHeaderCell--controlColumn emotion-euiDataGridHeaderCell"
data-gridcell-column-id="someControlColumn"
data-gridcell-column-index="0"
Expand All @@ -50,14 +50,8 @@ describe('EuiDataGridControlHeaderCell', () => {
tabindex="-1"
/>
<p
aria-hidden="true"
class="emotion-euiScreenReaderOnly"
id="euiDataGridCellHeader_generated-id_exited"
/>
<p
aria-hidden="true"
class="emotion-euiScreenReaderOnly"
id="euiDataGridCellHeader_generated-id_keyboardHint"
hidden=""
id="generated-id_focusTrapHint"
>
Press the Enter key to interact with this cell's contents.
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,8 @@ describe('EuiDataGridHeaderCellWrapper', () => {
Mock column actions
</button>
<p
aria-hidden="true"
class="emotion-euiScreenReaderOnly"
id="euiDataGridCellHeader_generated-id_exited"
/>
<p
aria-hidden="true"
class="emotion-euiScreenReaderOnly"
id="euiDataGridCellHeader_generated-id_keyboardHint"
hidden=""
id="generated-id_focusTrapHint"
>
Press the Enter key to interact with this cell's contents.
</p>
Expand Down
Loading