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

[EuiFlyoutBody] Add scrollableTabIndex prop #7061

Merged
merged 4 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const OpenCollapsibleNav: FunctionComponent<
export const KibanaExample: Story = {
render: ({ ...args }) => (
<OpenCollapsibleNav {...args}>
<EuiFlyoutBody>
<EuiFlyoutBody scrollableTabIndex={-1}>
<EuiCollapsibleNavItem title="Home" icon="home" isSelected href="#" />
<EuiCollapsibleNavItem
title="Recent"
Expand Down Expand Up @@ -288,7 +288,7 @@ export const KibanaExample: Story = {
export const SecurityExample: Story = {
render: ({ ...args }) => (
<OpenCollapsibleNav {...args}>
<EuiFlyoutBody>
<EuiFlyoutBody scrollableTabIndex={-1}>
<EuiCollapsibleNavItem
title="Recent"
icon="clock"
Expand Down
9 changes: 9 additions & 0 deletions src/components/flyout/flyout_body.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ describe('EuiFlyoutBody', () => {

expect(container.firstChild).toMatchSnapshot();
});

test('is rendered', () => {
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
const { container } = render(<EuiFlyoutBody scrollableTabIndex={-1} />);

expect(container.querySelector('.euiFlyoutBody__overflow')).toHaveAttribute(
'tabIndex',
'-1'
);
});
});
13 changes: 12 additions & 1 deletion src/components/flyout/flyout_body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,24 @@ export type EuiFlyoutBodyProps = FunctionComponent<
* Use to display a banner at the top of the body. It is suggested to use `EuiCallOut` for it.
*/
banner?: ReactNode;
/**
* [Scrollable regions (or their children) should be focusable](https://dequeuniversity.com/rules/axe/4.0/scrollable-region-focusable)
* to allow keyboard users to scroll the region via arrow keys.
*
* By default, EuiFlyoutBody's scroll overflow wrapper sets a `tabIndex` of `0`.
* If you know your flyout body content already contains focusable children
* that satisfy keyboard accessibility requirements, you can use this prop
* to override this default.
*/
scrollableTabIndex?: number;
}
>;

export const EuiFlyoutBody: EuiFlyoutBodyProps = ({
children,
className,
banner,
scrollableTabIndex = 0,
...rest
}) => {
const classes = classNames('euiFlyoutBody', className);
Expand All @@ -44,7 +55,7 @@ export const EuiFlyoutBody: EuiFlyoutBodyProps = ({
return (
<div className={classes} css={cssStyles} {...rest}>
<div
tabIndex={0}
tabIndex={scrollableTabIndex}
className="euiFlyoutBody__overflow"
css={overflowCssStyles}
>
Expand Down
1 change: 1 addition & 0 deletions upcoming_changelogs/7061.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Updated `EuiFlyoutBody` with a new `scrollableTabIndex` prop
Loading