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

[EuiDataGrid] Add keyboard shortcuts reference #6036

Merged
merged 16 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions src-docs/src/views/accessibility/screen_reader_focus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
EuiScreenReaderOnly,
EuiText,
EuiLink,
EuiToolTip,
EuiButtonIcon,
} from '../../../../src/components';

export default () => (
Expand All @@ -14,5 +16,15 @@ export default () => (
<EuiLink href="#/utilities/accessibility">Link text</EuiLink>
</EuiScreenReaderOnly>
</p>
<p>
This tooltip + button is visible on focus within:{' '}
<EuiScreenReaderOnly showOnFocus>
<span>
<EuiToolTip content="Information">
<EuiButtonIcon iconType="iInCircle" aria-label="Information" />
</EuiToolTip>
</span>
</EuiScreenReaderOnly>
</p>
</EuiText>
);
1 change: 1 addition & 0 deletions src-docs/src/views/datagrid/_snippets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ inMemory={{ level: 'sorting' }}`,
showColumnSelector: false,
showDisplaySelector: false,
showSortSelector: false,
showKeyboardShortcuts: false,
showFullScreenSelector: false,
additionalControls: {
left: <EuiButtonEmpty size="xs" />,
Expand Down
2 changes: 2 additions & 0 deletions src-docs/src/views/datagrid/toolbar/_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const DataGridStyle = ({
showColumnSelector,
showSortSelector,
showDisplaySelector,
showKeyboardShortcuts,
showFullScreenSelector,
allowDensity,
allowRowHeight,
Expand Down Expand Up @@ -114,6 +115,7 @@ const DataGridStyle = ({
showColumnSelector: toggleColumnSelector,
showSortSelector: showSortSelector,
showDisplaySelector: toggleDisplaySelector,
showKeyboardShortcuts: showKeyboardShortcuts,
showFullScreenSelector: showFullScreenSelector,
};

Expand Down
13 changes: 13 additions & 0 deletions src-docs/src/views/datagrid/toolbar/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const DataGrid = () => {
const [showColumnSelector, setShowColumnSelector] = useState(true);
const [allowHideColumns, setAllowHideColumns] = useState(true);
const [allowOrderingColumns, setAllowOrderingColumns] = useState(true);
const [showKeyboardShortcuts, setShowKeyboardShortcuts] = useState(true);
const [showFullScreenSelector, setShowFullScreenSelector] = useState(true);
const [toolbarType, setToolbarType] = useState('true');

Expand Down Expand Up @@ -76,6 +77,10 @@ const DataGrid = () => {
setAllowRowHeight(optionId === 'true');
};

const onShowKeyboardShortcutsChange = (optionId) => {
setShowKeyboardShortcuts(optionId === 'true');
};

const onShowFullScreenSelectorChange = (optionId) => {
setShowFullScreenSelector(optionId === 'true');
};
Expand Down Expand Up @@ -232,6 +237,13 @@ const DataGrid = () => {
</ul>
)}

<li>
{createItem('Show keyboard shortcuts', {
idSelected: showKeyboardShortcuts.toString(),
onChange: onShowKeyboardShortcutsChange,
})}
</li>

<li>
{createItem('Show full screen', {
idSelected: showFullScreenSelector.toString(),
Expand All @@ -250,6 +262,7 @@ const DataGrid = () => {
showColumnSelector={showColumnSelector}
showSortSelector={showSortSelector}
showDisplaySelector={showDisplaySelector}
showKeyboardShortcuts={showKeyboardShortcuts}
showFullScreenSelector={showFullScreenSelector}
allowDensity={allowDensity}
allowRowHeight={allowRowHeight}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ 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):not(:active):not(:focus-within) {
${euiScreenReaderOnly()}
}
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface EuiScreenReaderOnlyProps {
children: ReactElement;

/**
* For keyboard navigation, force content to display visually upon focus.
* For keyboard navigation, force content to display visually upon focus/focus-within.
*/
showOnFocus?: boolean;
className?: string;
Expand Down
112 changes: 108 additions & 4 deletions src/components/datagrid/__snapshots__/data_grid.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ Array [
>
<div
class="euiDataGrid__controls"
data-test-sub="dataGridControls"
data-test-subj="dataGridControls"
>
<div
class="euiDataGrid__leftControls"
Expand Down Expand Up @@ -517,6 +517,32 @@ Array [
<div
class="euiDataGrid__rightControls"
>
<div
class="euiPopover emotion-euiPopover"
data-test-subj="dataGridKeyboardShortcutsPopover"
>
<div
class="euiPopover__anchor css-16vtueo-render"
>
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-inlineBlock"
>
<button
aria-label="Keyboard shortcuts"
class="euiButtonIcon euiButtonIcon--xSmall emotion-euiButtonIcon-empty-text-hoverStyles"
data-test-subj="dataGridKeyboardShortcutsButton"
type="button"
>
<span
aria-hidden="true"
class="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="keyboard"
/>
</button>
</span>
</div>
</div>
<div
class="euiPopover emotion-euiPopover"
data-test-subj="dataGridDisplaySelectorPopover"
Expand Down Expand Up @@ -921,7 +947,7 @@ Array [
>
<div
class="euiDataGrid__controls"
data-test-sub="dataGridControls"
data-test-subj="dataGridControls"
>
<div
class="euiDataGrid__leftControls"
Expand Down Expand Up @@ -962,6 +988,32 @@ Array [
<div
class="euiDataGrid__rightControls"
>
<div
class="euiPopover emotion-euiPopover"
data-test-subj="dataGridKeyboardShortcutsPopover"
>
<div
class="euiPopover__anchor css-16vtueo-render"
>
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-inlineBlock"
>
<button
aria-label="Keyboard shortcuts"
class="euiButtonIcon euiButtonIcon--xSmall emotion-euiButtonIcon-empty-text-hoverStyles"
data-test-subj="dataGridKeyboardShortcutsButton"
type="button"
>
<span
aria-hidden="true"
class="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="keyboard"
/>
</button>
</span>
</div>
</div>
<div
class="euiPopover emotion-euiPopover"
data-test-subj="dataGridDisplaySelectorPopover"
Expand Down Expand Up @@ -1710,7 +1762,7 @@ Array [
>
<div
class="euiDataGrid__controls"
data-test-sub="dataGridControls"
data-test-subj="dataGridControls"
>
<div
class="euiDataGrid__leftControls"
Expand Down Expand Up @@ -1748,6 +1800,32 @@ Array [
<div
class="euiDataGrid__rightControls"
>
<div
class="euiPopover emotion-euiPopover"
data-test-subj="dataGridKeyboardShortcutsPopover"
>
<div
class="euiPopover__anchor css-16vtueo-render"
>
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-inlineBlock"
>
<button
aria-label="Keyboard shortcuts"
class="euiButtonIcon euiButtonIcon--xSmall emotion-euiButtonIcon-empty-text-hoverStyles"
data-test-subj="dataGridKeyboardShortcutsButton"
type="button"
>
<span
aria-hidden="true"
class="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="keyboard"
/>
</button>
</span>
</div>
</div>
<div
class="euiPopover emotion-euiPopover"
data-test-subj="dataGridDisplaySelectorPopover"
Expand Down Expand Up @@ -2154,7 +2232,7 @@ Array [
>
<div
class="euiDataGrid__controls"
data-test-sub="dataGridControls"
data-test-subj="dataGridControls"
>
<div
class="euiDataGrid__leftControls"
Expand Down Expand Up @@ -2192,6 +2270,32 @@ Array [
<div
class="euiDataGrid__rightControls"
>
<div
class="euiPopover emotion-euiPopover"
data-test-subj="dataGridKeyboardShortcutsPopover"
>
<div
class="euiPopover__anchor css-16vtueo-render"
>
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-inlineBlock"
>
<button
aria-label="Keyboard shortcuts"
class="euiButtonIcon euiButtonIcon--xSmall emotion-euiButtonIcon-empty-text-hoverStyles"
data-test-subj="dataGridKeyboardShortcutsButton"
type="button"
>
<span
aria-hidden="true"
class="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="keyboard"
/>
</button>
</span>
</div>
</div>
<div
class="euiPopover emotion-euiPopover"
data-test-subj="dataGridDisplaySelectorPopover"
Expand Down
1 change: 1 addition & 0 deletions src/components/datagrid/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
@import 'controls/data_grid_column_selector';
@import 'controls/data_grid_column_sorting';
@import 'controls/data_grid_display';
@import 'controls/data_grid_keyboard_shortcuts';
Loading