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

Clean up copy/pasting of tabular content in EuiDataGrid and EuiBasic/InMemoryTable #8019

Merged
merged 14 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
/>
</button>
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
<div
aria-describedby="euiDataGridCellHeader_generated-id_sorting"
Expand Down Expand Up @@ -92,6 +99,13 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
/>
</button>
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
</div>
<div
Expand All @@ -115,6 +129,13 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
>
hello
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
<div
aria-rowindex="1"
Expand All @@ -134,6 +155,13 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
>
world
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
</div>
<div
Expand All @@ -157,6 +185,13 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
>
lorem
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
<div
aria-rowindex="2"
Expand All @@ -176,6 +211,13 @@ exports[`EuiDataGridBodyCustomRender treats \`renderCustomGridBody\` as a render
>
ipsum
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ exports[`EuiDataGridBodyVirtualized renders 1`] = `
/>
</button>
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
<div
aria-describedby="euiDataGridCellHeader_generated-id_sorting"
Expand Down Expand Up @@ -96,6 +103,13 @@ exports[`EuiDataGridBodyVirtualized renders 1`] = `
/>
</button>
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
</div>
<div
Expand All @@ -118,6 +132,13 @@ exports[`EuiDataGridBodyVirtualized renders 1`] = `
cell content
</span>
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
<div
aria-rowindex="1"
Expand All @@ -139,6 +160,13 @@ exports[`EuiDataGridBodyVirtualized renders 1`] = `
cell content
</span>
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,12 @@ exports[`EuiDataGridCell renders 1`] = `
</button>
</div>
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import React, {
import { createPortal } from 'react-dom';

import { IS_JEST_ENVIRONMENT } from '../../../../utils';
import { keys, useEuiMemoizedStyles } from '../../../../services';
import {
keys,
tabularCopyMarkers,
useEuiMemoizedStyles,
} from '../../../../services';
import { EuiScreenReaderOnly } from '../../../accessibility';
import { useEuiI18n } from '../../../i18n';
import { EuiTextBlockTruncate } from '../../../text_truncate';
Expand Down Expand Up @@ -545,6 +549,12 @@ export class EuiDataGridCell extends Component<
className
);

// classNames set by EuiDataGridCellWrapper
const isControlColumn = cellClasses.includes(
'euiDataGridRowCell--controlColumn'
);
const isLastColumn = cellClasses.includes('euiDataGridRowCell--lastColumn');

const ariaRowIndex = pagination
? visibleRowIndex + 1 + pagination.pageSize * pagination.pageIndex
: visibleRowIndex + 1;
Expand Down Expand Up @@ -616,14 +626,16 @@ export class EuiDataGridCell extends Component<
setCellContentsRef={this.setCellContentsRef}
rowHeight={rowHeight}
rowHeightUtils={rowHeightUtils}
isControlColumn={cellClasses.includes(
'euiDataGridRowCell--controlColumn'
)}
isControlColumn={isControlColumn}
rowIndex={rowIndex}
colIndex={colIndex}
/>
</HandleInteractiveChildren>

{isLastColumn
? tabularCopyMarkers.hiddenNewline
: tabularCopyMarkers.hiddenTab}

{this.state.isFocused && (
<CellScreenReaderDescription
columnName={column?.displayAsText || this.props.columnId}
Expand Down Expand Up @@ -731,7 +743,11 @@ const CellScreenReaderDescription: FunctionComponent<{

return (
<EuiScreenReaderOnly>
<p>{` - ${cellPosition}${canExpandCell ? `. ${enterKeyPrompt}` : ''}`}</p>
<p>
{tabularCopyMarkers.ariaHiddenNoCopyBoundary}
{` - ${cellPosition}${canExpandCell ? `. ${enterKeyPrompt}` : ''}`}
{tabularCopyMarkers.ariaHiddenNoCopyBoundary}
</p>
</EuiScreenReaderOnly>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const EuiDataGridBodyCustomRender: FunctionComponent<
columnWidths,
defaultColumnWidth,
setColumnWidth,
visibleColCount,
setVisibleColumns,
switchColumnPos,
sorting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export const EuiDataGridBodyVirtualized: FunctionComponent<EuiDataGridBodyProps>
columnWidths,
defaultColumnWidth,
setColumnWidth,
visibleColCount,
setVisibleColumns,
switchColumnPos,
sorting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ describe('EuiDataGridFooterRow', () => {
>
<div />
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
<div
aria-rowindex="11"
Expand All @@ -69,6 +76,13 @@ describe('EuiDataGridFooterRow', () => {
>
<div />
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
</div>
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@ exports[`EuiDataGridHeaderCell renders 1`] = `
/>
</button>
</div>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { EuiDataGridControlHeaderCell } from './data_grid_control_header_cell';
describe('EuiDataGridControlHeaderCell', () => {
const props = {
index: 0,
visibleColCount: 1,
controlColumn: {
id: 'someControlColumn',
headerCellRender: () => <button data-euigrid-tab-managed="true" />,
Expand Down Expand Up @@ -61,6 +62,13 @@ describe('EuiDataGridControlHeaderCell', () => {
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;"
tabindex="-1"
/>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { EuiDataGridControlHeaderCellProps } from '../../data_grid_types';
import { EuiDataGridHeaderCellWrapper } from './data_grid_header_cell_wrapper';

export const EuiDataGridControlHeaderCell: FunctionComponent<EuiDataGridControlHeaderCellProps> =
memo(({ controlColumn, index }) => {
memo(({ controlColumn, index, visibleColCount }) => {
const {
headerCellRender: HeaderCellRender,
headerCellProps,
Expand All @@ -31,6 +31,7 @@ export const EuiDataGridControlHeaderCell: FunctionComponent<EuiDataGridControlH
id={id}
index={index}
width={width}
visibleColCount={visibleColCount}
>
<HeaderCellRender />
</EuiDataGridHeaderCellWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('EuiDataGridHeaderCell', () => {
schema: { someColumn: { columnType: 'numeric' } },
schemaDetectors: [],
setColumnWidth: jest.fn(),
visibleColCount: 1,
setVisibleColumns: jest.fn(),
switchColumnPos: jest.fn(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const EuiDataGridHeaderCell: FunctionComponent<EuiDataGridHeaderCellProps
columnWidths,
defaultColumnWidth,
setColumnWidth,
visibleColCount,
setVisibleColumns,
switchColumnPos,
sorting,
Expand Down Expand Up @@ -160,6 +161,7 @@ export const EuiDataGridHeaderCell: FunctionComponent<EuiDataGridHeaderCellProps
className={classes}
id={id}
index={index}
visibleColCount={visibleColCount}
width={width}
aria-sort={ariaSort}
hasActionsPopover={showColumnActions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('EuiDataGridHeaderCellWrapper', () => {
const requiredProps = {
id: 'someColumn',
index: 0,
visibleColCount: 1,
hasActionsPopover: true,
children: (
<>
Expand Down Expand Up @@ -62,6 +63,13 @@ describe('EuiDataGridHeaderCellWrapper', () => {
>
Mock column actions
</button>
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
`);
});
Expand All @@ -87,6 +95,13 @@ describe('EuiDataGridHeaderCellWrapper', () => {
tabindex="0"
>
No column actions
<span
aria-hidden="true"
class="euiScreenReaderOnly"
data-tabular-copy-marker="true"
>
</span>
</div>
`);
});
Expand Down
Loading