@patternfly/react-core 4.170.2 → 4.172.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.170.2",
3
+ "version": "4.172.0",
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.21.2",
38
- "@patternfly/react-styles": "^4.20.2",
39
- "@patternfly/react-tokens": "^4.22.2",
37
+ "@patternfly/react-icons": "^4.23.0",
38
+ "@patternfly/react-styles": "^4.22.0",
39
+ "@patternfly/react-tokens": "^4.24.0",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "10.2.2",
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": "2b543d27472e46aabb3e7c8d7b3769234ea7e138"
63
+ "gitHead": "ddafdb3da131c5e1e413f0d4bd36ba6daf0abbe3"
64
64
  }
@@ -100,6 +100,8 @@ export const JumpLinks: React.FunctionComponent<JumpLinksProps> = ({
100
100
  const [scrollItems, setScrollItems] = React.useState(hasScrollSpy ? getScrollItems(children, []) : []);
101
101
  const [activeIndex, setActiveIndex] = React.useState(activeIndexProp);
102
102
  const [isExpanded, setIsExpanded] = React.useState(isExpandedProp);
103
+ // Boolean to disable scroll listener from overriding active state of clicked jumplink
104
+ const isLinkClicked = React.useRef(false);
103
105
  // Allow expanding to be controlled for a niche use case
104
106
  React.useEffect(() => setIsExpanded(isExpandedProp), [isExpandedProp]);
105
107
  const navRef = React.useRef<HTMLElement>();
@@ -110,6 +112,10 @@ export const JumpLinks: React.FunctionComponent<JumpLinksProps> = ({
110
112
  if (!canUseDOM || !hasScrollSpy || !(scrollableElement instanceof HTMLElement)) {
111
113
  return;
112
114
  }
115
+ if (isLinkClicked.current) {
116
+ isLinkClicked.current = false;
117
+ return;
118
+ }
113
119
  const scrollPosition = Math.ceil(scrollableElement.scrollTop + offset);
114
120
  window.requestAnimationFrame(() => {
115
121
  let newScrollItems = scrollItems;
@@ -158,6 +164,7 @@ export const JumpLinks: React.FunctionComponent<JumpLinksProps> = ({
158
164
  const scrollItem = scrollItems[itemIndex];
159
165
  return React.cloneElement(child as React.ReactElement<JumpLinksItemProps>, {
160
166
  onClick(ev: React.MouseEvent<HTMLAnchorElement>) {
167
+ isLinkClicked.current = true;
161
168
  // Items might have rendered after this component. Do a quick refresh.
162
169
  let newScrollItems;
163
170
  if (!scrollItem) {
@@ -188,6 +195,7 @@ export const JumpLinks: React.FunctionComponent<JumpLinksProps> = ({
188
195
  }
189
196
  newScrollItem.focus();
190
197
  ev.preventDefault();
198
+ setActiveIndex(itemIndex);
191
199
  }
192
200
  if (onClickProp) {
193
201
  onClickProp(ev);
@@ -24,7 +24,7 @@ export const DrilldownMenu: React.FunctionComponent<DrilldownMenuProps> = ({
24
24
  }: DrilldownMenuProps) => (
25
25
  /* eslint-disable @typescript-eslint/no-unused-vars */
26
26
  <MenuContext.Consumer>
27
- {({ menuId, parentMenu, flyoutRef, setFlyoutRef, ...context }) => (
27
+ {({ menuId, parentMenu, flyoutRef, setFlyoutRef, disableHover, ...context }) => (
28
28
  <Menu
29
29
  id={id}
30
30
  parentMenu={menuId}
@@ -292,6 +292,104 @@ class NavExpandableTitlesList extends React.Component {
292
292
  }
293
293
  ```
294
294
 
295
+ ### Expandable third level
296
+
297
+ ```js
298
+ import React from 'react';
299
+ import { Nav, NavExpandable, NavItem, NavList } from '@patternfly/react-core';
300
+
301
+ NavExpandableThirdLevelList = () => {
302
+ const [activeGroup, setActiveGroup] = React.useState('grp-1');
303
+ const [activeItem, setActiveItem] = React.useState('grp-1_itm-1');
304
+
305
+ onSelect = result => {
306
+ setActiveGroup(result.groupId);
307
+ setActiveItem(result.itemId);
308
+ };
309
+
310
+ onToggle = result => {
311
+ // eslint-disable-next-line no-console
312
+ console.log(`Group ${result.groupId} expanded? ${result.isExpanded}`);
313
+ };
314
+
315
+ return (
316
+ <Nav onSelect={onSelect} onToggle={onToggle}>
317
+ <NavList>
318
+ <NavExpandable title="Link 1" groupId="grp-1" isActive={activeGroup === 'grp-1'} isExpanded>
319
+ <NavItem
320
+ preventDefault
321
+ to="#expandable-1"
322
+ groupId="grp-1"
323
+ itemId="grp-1_itm-1"
324
+ isActive={activeItem === 'grp-1_itm-1'}
325
+ >
326
+ Subnav Link 1
327
+ </NavItem>
328
+ <NavItem
329
+ preventDefault
330
+ to="#expandable-2"
331
+ groupId="grp-1"
332
+ itemId="grp-1_itm-2"
333
+ isActive={activeItem === 'grp-1_itm-2'}
334
+ >
335
+ Subnav Link 2
336
+ </NavItem>
337
+ <NavItem
338
+ preventDefault
339
+ to="#expandable-3"
340
+ groupId="grp-1"
341
+ itemId="grp-1_itm-3"
342
+ isActive={activeItem === 'grp-1_itm-3'}
343
+ >
344
+ Subnav Link 3
345
+ </NavItem>
346
+ </NavExpandable>
347
+ <NavExpandable title="Link 2" groupId="grp-2" isActive={activeGroup === 'grp-2'} isExpanded>
348
+ <NavItem
349
+ preventDefault
350
+ to="#expandable-4"
351
+ groupId="grp-2"
352
+ itemId="grp-2_itm-1"
353
+ isActive={activeItem === 'grp-2_itm-1'}
354
+ >
355
+ Subnav Link 1
356
+ </NavItem>
357
+ <NavExpandable title="Third Level" groupId="grp-3" isActive={activeGroup === 'grp-3'} isExpanded>
358
+ <NavItem
359
+ preventDefault
360
+ to="#expandable-6"
361
+ groupId="grp-3"
362
+ itemId="grp-3_itm-1"
363
+ isActive={activeItem === 'grp-3_itm-1'}
364
+ >
365
+ Third Level Link 1
366
+ </NavItem>
367
+ <NavItem
368
+ preventDefault
369
+ to="#expandable-7"
370
+ groupId="grp-3"
371
+ itemId="grp-3_itm-2"
372
+ isActive={activeItem === 'grp-3_itm-2'}
373
+ >
374
+ Third Level Link 2
375
+ </NavItem>
376
+ </NavExpandable>
377
+ <NavItem
378
+ preventDefault
379
+ to="#expandable-8"
380
+ groupId="grp-2"
381
+ itemId="grp-2_itm-2"
382
+ isActive={activeItem === 'grp-2_itm-3'}
383
+ >
384
+ Subnav Link 3
385
+ </NavItem>
386
+ </NavExpandable>
387
+ </NavList>
388
+ </Nav>
389
+ );
390
+ }
391
+ ```
392
+
295
393
  ### Mixed
296
394
 
297
395
  ```js
@@ -4,6 +4,7 @@
4
4
  #ws-react-c-navigation-expandable,
5
5
  #ws-react-c-navigation-expandable-wsubnavigation-titles,
6
6
  #ws-react-c-navigation-mixed,
7
+ #ws-react-c-navigation-expandable-third-level,
7
8
  #ws-react-c-navigation-horizontal-subnav,
8
9
  #ws-react-c-navigation-flyout {
9
10
  background-color: var(--pf-global--BackgroundColor--dark-300);