diff --git a/packages/react-core/src/components/Drawer/DrawerPanelContent.tsx b/packages/react-core/src/components/Drawer/DrawerPanelContent.tsx index d929c19d396..0a98f7c0fd2 100644 --- a/packages/react-core/src/components/Drawer/DrawerPanelContent.tsx +++ b/packages/react-core/src/components/Drawer/DrawerPanelContent.tsx @@ -4,6 +4,22 @@ import { css } from '@patternfly/react-styles'; import { DrawerColorVariant, DrawerContext } from './Drawer'; import { formatBreakpointMods } from '../../helpers/util'; import { GenerateId } from '../../helpers/GenerateId/GenerateId'; +import { FocusTrap } from '../../helpers/FocusTrap/FocusTrap'; + +export interface DrawerPanelFocusTrapObject { + /** Enables a focus trap on the drawer panel content. This will also automatically + * handle focus management when the panel expands and when it collapses. Do not pass + * this prop if the isStatic prop on the drawer component is true. + */ + enabled?: boolean; + /** The element to focus when the drawer panel content expands. By default the + * first focusable element will receive focus. If there are no focusable elements, the + * panel itself will receive focus. + */ + elementToFocusOnExpand?: HTMLElement | SVGElement | string; + /** One or more id's to use for the drawer panel content's accessible label. */ + 'aria-labelledby'?: string; +} export interface DrawerPanelContentProps extends React.HTMLProps { /** Additional classes added to the drawer. */ @@ -37,6 +53,8 @@ export interface DrawerPanelContentProps extends React.HTMLProps }; /** Color variant of the background of the drawer panel */ colorVariant?: DrawerColorVariant | 'light-200' | 'no-background' | 'default'; + /** Adds and customizes a focus trap on the drawer panel content. */ + focusTrap?: DrawerPanelFocusTrapObject; } let isResizing: boolean = null; let newSize: number = 0; @@ -55,6 +73,7 @@ export const DrawerPanelContent: React.FunctionComponent { const panel = React.useRef(); @@ -64,6 +83,8 @@ export const DrawerPanelContent: React.FunctionComponent