| 1 |
--- |
| 2 |
id: Notification drawer |
| 3 |
section: components |
| 4 |
--- |
| 5 |
|
| 6 |
import { Fragment, useRef, useState } from 'react'; |
| 7 |
|
| 8 |
import RhUiNotificationFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-notification-fill-icon'; |
| 9 |
import RhUiSettingsFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-settings-fill-icon'; |
| 10 |
import RhUiMenuBarsIcon from '@patternfly/react-icons/dist/js/icons/rh-ui-menu-bars-icon'; |
| 11 |
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon'; |
| 12 |
import RhUiQuestionMarkCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-question-mark-circle-fill-icon'; |
| 13 |
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; |
| 14 |
import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg'; |
| 15 |
import RhUiEllipsisVerticalFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ellipsis-vertical-fill-icon'; |
| 16 |
import pfLogo from '@patternfly/react-core/src/demos/assets/PF-HorizontalLogo-Color.svg'; |
| 17 |
|
| 18 |
## Demos |
| 19 |
|
| 20 |
- Focus must be manually managed when the NotificationDrawer component is opened: |
| 21 |
1. Create a React `ref` and pass it into the NotificationDrawer component's `ref` attribute |
| 22 |
2. Pass in a function to the `onNotificationDrawerExpand` prop of the Page component that will place focus on the first interact-able element inside the NotificationDrawer component via the previously created `ref` |
| 23 |
|
| 24 |
### Basic |
| 25 |
|
| 26 |
```ts file='./examples/NotificationDrawerBasic.tsx' isFullscreen |
| 27 |
|
| 28 |
``` |
| 29 |
|
| 30 |
### Grouped |
| 31 |
|
| 32 |
When using the NotificationDrawerGroupList and related components, the function that is passed in to the `onNotificationDrawerExpand` prop on the Page component must also ensure the NotificationDrawer component only receives focus when it is initially opened. Otherwise any time a drawer group item is opened the NotificationDrawer component will receive focus, which would be unexpected behavior for users. |
| 33 |
|
| 34 |
```ts file='./examples/NotificationDrawerGrouped.tsx' isFullscreen |
| 35 |
|
| 36 |
``` |