@patternfly/react-core 4.170.3 → 4.170.4

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.3",
3
+ "version": "4.170.4",
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.3",
38
- "@patternfly/react-styles": "^4.20.3",
39
- "@patternfly/react-tokens": "^4.22.3",
37
+ "@patternfly/react-icons": "^4.21.4",
38
+ "@patternfly/react-styles": "^4.20.4",
39
+ "@patternfly/react-tokens": "^4.22.4",
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": "0c1fea3b72c8dfc497db8c846c57741dfef5b248"
63
+ "gitHead": "df020bd8e2856618704752b1ee626f8f06f0d464"
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);