diff --git a/src-docs/src/views/accessibility/accessibility_example.js b/src-docs/src/views/accessibility/accessibility_example.js
index 60ee25bfede..309724778bc 100644
--- a/src-docs/src/views/accessibility/accessibility_example.js
+++ b/src-docs/src/views/accessibility/accessibility_example.js
@@ -15,6 +15,7 @@ import {
import ScreenReaderLive from './screen_reader_live';
import ScreenReaderLiveFocus from './screen_reader_live_focus';
import ScreenReaderOnly from './screen_reader';
+import ScreenReaderPreventCopy from './screen_reader_prevent_copy';
import ScreenReaderFocus from './screen_reader_focus';
import SkipLink from './skip_link';
import StylesHelpers from './styles_helpers';
@@ -22,6 +23,7 @@ import StylesHelpers from './styles_helpers';
const screenReaderLiveSource = require('!!raw-loader!./screen_reader_live');
const screenReaderLiveFocusSource = require('!!raw-loader!./screen_reader_live_focus');
const screenReaderOnlySource = require('!!raw-loader!./screen_reader');
+const screenReaderPreventCopySource = require('!!raw-loader!./screen_reader_prevent_copy');
const screenReaderFocusSource = require('!!raw-loader!./screen_reader_focus');
const skipLinkSource = require('!!raw-loader!./skip_link');
@@ -74,7 +76,8 @@ export const AccessibilityExample = {
- Using a screen reader, verify that there is a second paragraph. + Use a screen reader, or select and copy both lines in the below + demo, to verify that there is a second paragraph.
> @@ -87,6 +90,38 @@ export const AccessibilityExample = { `, demo:
+ As you may have noticed in the previous demo, screen reader only
+ text is still selectable and copyable. If for any reason you do not
+ want this behavior, simply use the
+ + Select and copy both lines in the below demo and confirm only the + visible lines are copied. + +
+ > + ), + props: { + EuiScreenReaderOnly, + }, + snippet: `
If the wrapped element is focusable, you must use
the This is the first paragraph. It is visible and copyable.
+ This is the second paragraph. It is hidden for sighted users, and is not
+ selectable or copyable by users, but remains visible to screen readers.
+ This is the third paragraph. It is visible and copyable.
- This paragraph is not visibile to sighted users but will be read by screenreaders. + This paragraph is not visible to sighted users but will be read by screenreaders.
`; -exports[`EuiScreenReaderOnly will show on focus 1`] = ` +exports[`EuiScreenReaderOnly preventCopy 1`] = ` + + Text + +`; + +exports[`EuiScreenReaderOnly showOnFocus 1`] = ` Link diff --git a/src/components/accessibility/screen_reader_only/screen_reader_only.styles.ts b/src/components/accessibility/screen_reader_only/screen_reader_only.styles.ts index 3599923538a..0983d2847b4 100644 --- a/src/components/accessibility/screen_reader_only/screen_reader_only.styles.ts +++ b/src/components/accessibility/screen_reader_only/screen_reader_only.styles.ts @@ -34,13 +34,18 @@ export const euiScreenReaderOnly = () => ` /* * Styles */ -export const euiScreenReaderOnlyStyles = (showOnFocus?: boolean) => ({ - euiScreenReaderOnly: showOnFocus - ? css` - // The :active selector is necessary for Safari which removes :focus when a button is pressed - &:not(:focus):not(:active):not(:focus-within) { - ${euiScreenReaderOnly()} - } - ` - : css(euiScreenReaderOnly()), +export const euiScreenReaderOnlyStyles = () => ({ + // Note: the default SR only CSS and `showOnFocus` CSS are mutually exclusive + euiScreenReaderOnly: css` + ${euiScreenReaderOnly()} + `, + 'euiScreenReaderOnly-showOnFocus': css` + // The :active selector is necessary for Safari which removes :focus when a button is pressed + &:not(:focus):not(:active):not(:focus-within) { + ${euiScreenReaderOnly()} + } + `, + preventCopy: css` + user-select: none; + `, }); diff --git a/src/components/accessibility/screen_reader_only/screen_reader_only.test.tsx b/src/components/accessibility/screen_reader_only/screen_reader_only.test.tsx index 5adeb8dad54..83fed7298ea 100644 --- a/src/components/accessibility/screen_reader_only/screen_reader_only.test.tsx +++ b/src/components/accessibility/screen_reader_only/screen_reader_only.test.tsx @@ -17,7 +17,7 @@ describe('EuiScreenReaderOnly', () => { const $paragraph = render(- This paragraph is not visibile to sighted users but will be read by + This paragraph is not visible to sighted users but will be read by screenreaders.
- This paragraph is not visibile to sighted users but will be read by + This paragraph is not visible to sighted users but will be read by screenreaders.
- A, column 1, row 1
@@ -767,8 +766,7 @@ Array [ 0, B- B, column 2, row 1
@@ -800,8 +798,7 @@ Array [ 1, A- A, column 1, row 2
@@ -833,8 +830,7 @@ Array [ 1, B- B, column 2, row 2
@@ -866,8 +862,7 @@ Array [ 2, A- A, column 1, row 3
@@ -899,8 +894,7 @@ Array [ 2, B- B, column 2, row 3
@@ -1252,8 +1246,7 @@ Array [ 0- leading, column 1, row 1
@@ -1291,8 +1284,7 @@ Array [ 0, A- A, column 2, row 1
@@ -1324,8 +1316,7 @@ Array [ 0, B- B, column 3, row 1
@@ -1365,8 +1356,7 @@ Array [ 0- trailing, column 4, row 1
@@ -1412,8 +1402,7 @@ Array [ 1- leading, column 1, row 2
@@ -1451,8 +1440,7 @@ Array [ 1, A- A, column 2, row 2
@@ -1484,8 +1472,7 @@ Array [ 1, B- B, column 3, row 2
@@ -1525,8 +1512,7 @@ Array [ 1- trailing, column 4, row 2
@@ -1572,8 +1558,7 @@ Array [ 2- leading, column 1, row 3
@@ -1611,8 +1596,7 @@ Array [ 2, A- A, column 2, row 3
@@ -1644,8 +1628,7 @@ Array [ 2, B- B, column 3, row 3
@@ -1685,8 +1668,7 @@ Array [ 2- trailing, column 4, row 3
@@ -1997,8 +1979,7 @@ Array [ 0, A- A, column 1, row 1
@@ -2030,8 +2011,7 @@ Array [ 0, B- B, column 2, row 1
@@ -2063,8 +2043,7 @@ Array [ 1, A- A, column 1, row 2
@@ -2096,8 +2075,7 @@ Array [ 1, B- B, column 2, row 2
@@ -2129,8 +2107,7 @@ Array [ 2, A- A, column 1, row 3
@@ -2162,8 +2139,7 @@ Array [ 2, B- B, column 2, row 3
@@ -2466,8 +2442,7 @@ Array [ 0, A- A, column 1, row 1
@@ -2499,8 +2474,7 @@ Array [ 0, B- B, column 2, row 1
@@ -2532,8 +2506,7 @@ Array [ 1, A- A, column 1, row 2
@@ -2565,8 +2538,7 @@ Array [ 1, B- B, column 2, row 2
@@ -2598,8 +2570,7 @@ Array [ 2, A- A, column 1, row 3
@@ -2631,8 +2602,7 @@ Array [ 2, B- B, column 2, row 3
diff --git a/src/components/datagrid/body/__snapshots__/data_grid_body_custom.test.tsx.snap b/src/components/datagrid/body/__snapshots__/data_grid_body_custom.test.tsx.snap index bce634a36b1..a4be2ea4b04 100644 --- a/src/components/datagrid/body/__snapshots__/data_grid_body_custom.test.tsx.snap +++ b/src/components/datagrid/body/__snapshots__/data_grid_body_custom.test.tsx.snap @@ -146,8 +146,7 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render hello- columnA, column 1, row 1 @@ -180,8 +179,7 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render world
- columnB, column 2, row 1 @@ -218,8 +216,7 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render lorem
- columnA, column 1, row 2 @@ -252,8 +249,7 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render ipsum
- columnB, column 2, row 2 diff --git a/src/components/datagrid/body/__snapshots__/data_grid_body_virtualized.test.tsx.snap b/src/components/datagrid/body/__snapshots__/data_grid_body_virtualized.test.tsx.snap index d011615e722..e8d8784c071 100644 --- a/src/components/datagrid/body/__snapshots__/data_grid_body_virtualized.test.tsx.snap +++ b/src/components/datagrid/body/__snapshots__/data_grid_body_virtualized.test.tsx.snap @@ -145,8 +145,7 @@ exports[`EuiDataGridBodyVirtualized renders 1`] = `
- columnA, column 1, row 1
@@ -180,8 +179,7 @@ exports[`EuiDataGridBodyVirtualized renders 1`] = `- columnB, column 2, row 1
diff --git a/src/components/datagrid/body/__snapshots__/data_grid_cell.test.tsx.snap b/src/components/datagrid/body/__snapshots__/data_grid_cell.test.tsx.snap index a652e4938d7..9267e0c7674 100644 --- a/src/components/datagrid/body/__snapshots__/data_grid_cell.test.tsx.snap +++ b/src/components/datagrid/body/__snapshots__/data_grid_cell.test.tsx.snap @@ -72,8 +72,7 @@ exports[`EuiDataGridCell renders 1`] = `- someColumn, column 1, row 1
diff --git a/src/components/datagrid/body/data_grid_cell.tsx b/src/components/datagrid/body/data_grid_cell.tsx index 12af15fa800..6a0112c54e0 100644 --- a/src/components/datagrid/body/data_grid_cell.tsx +++ b/src/components/datagrid/body/data_grid_cell.tsx @@ -47,7 +47,6 @@ const EuiDataGridCellContent: FunctionComponent< setCellContentsRef: EuiDataGridCell['setCellContentsRef']; isExpanded: boolean; isDefinedHeight: boolean; - isFocused: boolean; ariaRowIndex: number; } > = memo( @@ -61,7 +60,6 @@ const EuiDataGridCellContent: FunctionComponent< ariaRowIndex, rowHeightUtils, isDefinedHeight, - isFocused, ...rest }) => { // React is more permissible than the TS types indicate @@ -93,8 +91,8 @@ const EuiDataGridCellContent: FunctionComponent< {...rest} /> -
+
{'- '}
{sortingScreenReaderText}