Skip to content

Commit

Permalink
[EuiDataGrid] Reduce hidden SR text when copying text from multiple c…
Browse files Browse the repository at this point in the history
…ells (elastic#6817)

* Hide cell position SR text if cell is not focused

* changelog
  • Loading branch information
cee-chen authored May 26, 2023
1 parent a1ee487 commit 48c957b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/components/datagrid/__snapshots__/data_grid.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 1, row 1
</p>
Expand Down Expand Up @@ -767,6 +768,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 2, row 1
</p>
Expand Down Expand Up @@ -799,6 +801,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 1, row 2
</p>
Expand Down Expand Up @@ -831,6 +834,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 2, row 2
</p>
Expand Down Expand Up @@ -863,6 +867,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 1, row 3
</p>
Expand Down Expand Up @@ -895,6 +900,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 2, row 3
</p>
Expand Down Expand Up @@ -1247,6 +1253,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- leading, column 1, row 1
</p>
Expand Down Expand Up @@ -1285,6 +1292,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 2, row 1
</p>
Expand Down Expand Up @@ -1317,6 +1325,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 3, row 1
</p>
Expand Down Expand Up @@ -1357,6 +1366,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- trailing, column 4, row 1
</p>
Expand Down Expand Up @@ -1403,6 +1413,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- leading, column 1, row 2
</p>
Expand Down Expand Up @@ -1441,6 +1452,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 2, row 2
</p>
Expand Down Expand Up @@ -1473,6 +1485,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 3, row 2
</p>
Expand Down Expand Up @@ -1513,6 +1526,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- trailing, column 4, row 2
</p>
Expand Down Expand Up @@ -1559,6 +1573,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- leading, column 1, row 3
</p>
Expand Down Expand Up @@ -1597,6 +1612,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 2, row 3
</p>
Expand Down Expand Up @@ -1629,6 +1645,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 3, row 3
</p>
Expand Down Expand Up @@ -1669,6 +1686,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- trailing, column 4, row 3
</p>
Expand Down Expand Up @@ -1980,6 +1998,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 1, row 1
</p>
Expand Down Expand Up @@ -2012,6 +2031,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 2, row 1
</p>
Expand Down Expand Up @@ -2044,6 +2064,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 1, row 2
</p>
Expand Down Expand Up @@ -2076,6 +2097,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 2, row 2
</p>
Expand Down Expand Up @@ -2108,6 +2130,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 1, row 3
</p>
Expand Down Expand Up @@ -2140,6 +2163,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 2, row 3
</p>
Expand Down Expand Up @@ -2443,6 +2467,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 1, row 1
</p>
Expand Down Expand Up @@ -2475,6 +2500,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 2, row 1
</p>
Expand Down Expand Up @@ -2507,6 +2533,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 1, row 2
</p>
Expand Down Expand Up @@ -2539,6 +2566,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 2, row 2
</p>
Expand Down Expand Up @@ -2571,6 +2599,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- A, column 1, row 3
</p>
Expand Down Expand Up @@ -2603,6 +2632,7 @@ Array [
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- B, column 2, row 3
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
-
columnA, column 1, row 1
Expand Down Expand Up @@ -180,6 +181,7 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
-
columnB, column 2, row 1
Expand Down Expand Up @@ -217,6 +219,7 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
-
columnA, column 1, row 2
Expand Down Expand Up @@ -250,6 +253,7 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
-
columnB, column 2, row 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ exports[`EuiDataGridBodyVirtualized renders 1`] = `
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- columnA, column 1, row 1
</p>
Expand Down Expand Up @@ -180,6 +181,7 @@ exports[`EuiDataGridBodyVirtualized renders 1`] = `
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- columnB, column 2, row 1
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ exports[`EuiDataGridCell renders 1`] = `
</div>
<p
class="emotion-euiScreenReaderOnly"
hidden=""
>
- someColumn, column 1, row 1
</p>
Expand Down
5 changes: 4 additions & 1 deletion src/components/datagrid/body/data_grid_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const EuiDataGridCellContent: FunctionComponent<
setCellContentsRef: EuiDataGridCell['setCellContentsRef'];
isExpanded: boolean;
isDefinedHeight: boolean;
isFocused: boolean;
ariaRowIndex: number;
}
> = memo(
Expand All @@ -60,6 +61,7 @@ const EuiDataGridCellContent: FunctionComponent<
ariaRowIndex,
rowHeightUtils,
isDefinedHeight,
isFocused,
...rest
}) => {
// React is more permissible than the TS types indicate
Expand Down Expand Up @@ -92,7 +94,7 @@ const EuiDataGridCellContent: FunctionComponent<
/>
</div>
<EuiScreenReaderOnly>
<p>
<p hidden={!isFocused}>
{'- '}
<EuiI18n
token="euiDataGridCell.position"
Expand Down Expand Up @@ -660,6 +662,7 @@ export class EuiDataGridCell extends Component<
isExpandable,
isExpanded: popoverIsOpen,
isDetails: false,
isFocused: this.state.isFocused,
setCellContentsRef: this.setCellContentsRef,
rowHeightsOptions,
rowHeightUtils,
Expand Down
1 change: 1 addition & 0 deletions upcoming_changelogs/6817.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Updated `EuiDataGrid` to only render screen reader text announcing cell position if the cell is currently focused. This should improve the ability to copy and paste multiple cells without SR text.

0 comments on commit 48c957b

Please sign in to comment.