@patternfly/react-core 4.198.13 → 4.198.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/esm/components/NotificationDrawer/NotificationDrawer.d.ts +3 -1
- package/dist/esm/components/NotificationDrawer/NotificationDrawer.d.ts.map +1 -1
- package/dist/esm/components/NotificationDrawer/NotificationDrawer.js +4 -3
- package/dist/esm/components/NotificationDrawer/NotificationDrawer.js.map +1 -1
- package/dist/js/components/NotificationDrawer/NotificationDrawer.d.ts +3 -1
- package/dist/js/components/NotificationDrawer/NotificationDrawer.d.ts.map +1 -1
- package/dist/js/components/NotificationDrawer/NotificationDrawer.js +4 -4
- package/dist/js/components/NotificationDrawer/NotificationDrawer.js.map +1 -1
- package/dist/umd/react-core.js +4 -3
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/NotificationDrawer/NotificationDrawer.tsx +8 -2
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawer.test.tsx.snap +1 -1
- package/src/demos/NotificationDrawer/NotificationDrawer.md +26 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.198.
|
|
3
|
+
"version": "4.198.14",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.49.
|
|
38
|
-
"@patternfly/react-styles": "^4.48.
|
|
39
|
-
"@patternfly/react-tokens": "^4.50.
|
|
37
|
+
"@patternfly/react-icons": "^4.49.14",
|
|
38
|
+
"@patternfly/react-styles": "^4.48.14",
|
|
39
|
+
"@patternfly/react-tokens": "^4.50.14",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "94e4c0985dd4cad90d4551cead82695a7e854332"
|
|
64
64
|
}
|
|
@@ -8,15 +8,21 @@ export interface NotificationDrawerProps extends React.HTMLProps<HTMLDivElement>
|
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
/** Additional classes added to the notification drawer */
|
|
10
10
|
className?: string;
|
|
11
|
+
/** @hide Forwarded ref */
|
|
12
|
+
innerRef?: React.Ref<any>;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
const NotificationDrawerBase: React.FunctionComponent<NotificationDrawerProps> = ({
|
|
14
16
|
children,
|
|
15
17
|
className = '',
|
|
18
|
+
innerRef,
|
|
16
19
|
...props
|
|
17
20
|
}: NotificationDrawerProps) => (
|
|
18
|
-
<div {...props} className={css(styles.notificationDrawer, className)}>
|
|
21
|
+
<div ref={innerRef} {...props} className={css(styles.notificationDrawer, className)}>
|
|
19
22
|
{children}
|
|
20
23
|
</div>
|
|
21
24
|
);
|
|
25
|
+
export const NotificationDrawer = React.forwardRef((props: NotificationDrawerProps, ref: React.Ref<any>) => (
|
|
26
|
+
<NotificationDrawerBase innerRef={ref} {...props} />
|
|
27
|
+
));
|
|
22
28
|
NotificationDrawer.displayName = 'NotificationDrawer';
|
package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawer.test.tsx.snap
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`className is added to the root element 1`] = `"
|
|
3
|
+
exports[`className is added to the root element 1`] = `"extra-class"`;
|
|
4
4
|
|
|
5
5
|
exports[`renders with PatternFly Core styles 1`] = `
|
|
6
6
|
<div>
|
|
@@ -16,6 +16,11 @@ import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-
|
|
|
16
16
|
|
|
17
17
|
## Demos
|
|
18
18
|
|
|
19
|
+
- Focus must be manually managed when the NotificationDrawer component is opened:
|
|
20
|
+
|
|
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
|
+
|
|
19
24
|
### Basic
|
|
20
25
|
|
|
21
26
|
```js isFullscreen
|
|
@@ -87,6 +92,7 @@ import { Table, TableHeader, TableBody } from '@patternfly/react-table';
|
|
|
87
92
|
class BasicNotificationDrawer extends React.Component {
|
|
88
93
|
constructor(props) {
|
|
89
94
|
super(props);
|
|
95
|
+
this.drawerRef = React.createRef();
|
|
90
96
|
this.state = {
|
|
91
97
|
isDropdownOpen: false,
|
|
92
98
|
isKebabDropdownOpen: false,
|
|
@@ -179,6 +185,11 @@ class BasicNotificationDrawer extends React.Component {
|
|
|
179
185
|
showNotifications: showNotifications
|
|
180
186
|
});
|
|
181
187
|
};
|
|
188
|
+
|
|
189
|
+
this.focusDrawer = () => {
|
|
190
|
+
const firstTabbableItem = this.drawerRef.current.querySelector('a, button');
|
|
191
|
+
firstTabbableItem.focus();
|
|
192
|
+
};
|
|
182
193
|
}
|
|
183
194
|
|
|
184
195
|
render() {
|
|
@@ -359,7 +370,7 @@ class BasicNotificationDrawer extends React.Component {
|
|
|
359
370
|
];
|
|
360
371
|
|
|
361
372
|
const notificationDrawer = (
|
|
362
|
-
<NotificationDrawer>
|
|
373
|
+
<NotificationDrawer ref={this.drawerRef}>
|
|
363
374
|
<NotificationDrawerHeader count={this.getNumberUnread()} onClose={this.onCloseNotificationDrawer}>
|
|
364
375
|
<Dropdown
|
|
365
376
|
onSelect={this.onSelect}
|
|
@@ -499,6 +510,7 @@ class BasicNotificationDrawer extends React.Component {
|
|
|
499
510
|
sidebar={Sidebar}
|
|
500
511
|
isManagedSidebar
|
|
501
512
|
notificationDrawer={notificationDrawer}
|
|
513
|
+
onNotificationDrawerExpand={this.focusDrawer}
|
|
502
514
|
isNotificationDrawerExpanded={isDrawerExpanded}
|
|
503
515
|
skipToContent={PageSkipToContent}
|
|
504
516
|
breadcrumb={PageBreadcrumb}
|
|
@@ -525,6 +537,8 @@ class BasicNotificationDrawer extends React.Component {
|
|
|
525
537
|
|
|
526
538
|
### Grouped
|
|
527
539
|
|
|
540
|
+
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.
|
|
541
|
+
|
|
528
542
|
```js isFullscreen
|
|
529
543
|
import React from 'react';
|
|
530
544
|
import {
|
|
@@ -597,6 +611,7 @@ import { Table, TableHeader, TableBody } from '@patternfly/react-table';
|
|
|
597
611
|
class GroupedNotificationDrawer extends React.Component {
|
|
598
612
|
constructor(props) {
|
|
599
613
|
super(props);
|
|
614
|
+
this.drawerRef = React.createRef();
|
|
600
615
|
this.state = {
|
|
601
616
|
isDropdownOpen: false,
|
|
602
617
|
isKebabDropdownOpen: false,
|
|
@@ -736,6 +751,14 @@ class GroupedNotificationDrawer extends React.Component {
|
|
|
736
751
|
thirdDrawerGroupExpanded: value
|
|
737
752
|
});
|
|
738
753
|
};
|
|
754
|
+
|
|
755
|
+
this.focusDrawer = () => {
|
|
756
|
+
// Prevent the NotificationDrawer from receiving focus if a drawer group item is opened
|
|
757
|
+
if (!document.activeElement.closest(`.${this.drawerRef.current.className}`)) {
|
|
758
|
+
const firstTabbableItem = this.drawerRef.current.querySelector('a, button');
|
|
759
|
+
firstTabbableItem.focus();
|
|
760
|
+
}
|
|
761
|
+
};
|
|
739
762
|
}
|
|
740
763
|
|
|
741
764
|
render() {
|
|
@@ -919,7 +942,7 @@ class GroupedNotificationDrawer extends React.Component {
|
|
|
919
942
|
];
|
|
920
943
|
|
|
921
944
|
const notificationDrawer = (
|
|
922
|
-
<NotificationDrawer>
|
|
945
|
+
<NotificationDrawer ref={this.drawerRef}>
|
|
923
946
|
<NotificationDrawerHeader count={this.getNumberUnread()} onClose={this.onCloseNotificationDrawer}>
|
|
924
947
|
<Dropdown
|
|
925
948
|
onSelect={this.onSelect}
|
|
@@ -1214,6 +1237,7 @@ class GroupedNotificationDrawer extends React.Component {
|
|
|
1214
1237
|
isManagedSidebar
|
|
1215
1238
|
notificationDrawer={notificationDrawer}
|
|
1216
1239
|
isNotificationDrawerExpanded={isDrawerExpanded}
|
|
1240
|
+
onNotificationDrawerExpand={this.focusDrawer}
|
|
1217
1241
|
skipToContent={PageSkipToContent}
|
|
1218
1242
|
breadcrumb={PageBreadcrumb}
|
|
1219
1243
|
mainContainerId={pageId}
|