@patternfly/react-core 4.236.4 → 4.236.7

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.236.4",
3
+ "version": "4.236.7",
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",
@@ -44,9 +44,9 @@
44
44
  "generate": "node scripts/copyStyles.js"
45
45
  },
46
46
  "dependencies": {
47
- "@patternfly/react-icons": "^4.87.4",
48
- "@patternfly/react-styles": "^4.86.4",
49
- "@patternfly/react-tokens": "^4.88.4",
47
+ "@patternfly/react-icons": "^4.87.7",
48
+ "@patternfly/react-styles": "^4.86.7",
49
+ "@patternfly/react-tokens": "^4.88.7",
50
50
  "focus-trap": "6.9.2",
51
51
  "react-dropzone": "9.0.0",
52
52
  "tippy.js": "5.1.2",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8.0 || ^17.0.0",
71
71
  "react-dom": "^16.8.0 || ^17.0.0"
72
72
  },
73
- "gitHead": "c1df72da34f893c6edb6d68d7bf2083bb2d7037c"
73
+ "gitHead": "9146bf58545f6e745af4b8ba31a22e1da35b077e"
74
74
  }
@@ -172,7 +172,7 @@ export class MenuToggleBase extends React.Component<MenuToggleProps> {
172
172
  }
173
173
  }
174
174
 
175
- export const MenuToggle = React.forwardRef<MenuToggleElement, MenuToggleProps>((props, ref) => (
175
+ export const MenuToggle = React.forwardRef((props: MenuToggleProps, ref: React.Ref<MenuToggleElement>) => (
176
176
  <MenuToggleBase innerRef={ref} {...props} />
177
177
  ));
178
178
 
@@ -197,8 +197,17 @@ export class Page extends React.Component<PageProps, PageState> {
197
197
  if (mobileView !== this.state.mobileView) {
198
198
  this.setState({ mobileView });
199
199
  }
200
- this.pageRef.current &&
201
- this.setState({ width: this.pageRef.current.clientWidth, height: this.pageRef.current.clientHeight });
200
+ if (this.pageRef?.current) {
201
+ const currentWidth = this.pageRef.current.clientWidth;
202
+ const currentHeight = this.pageRef.current.clientHeight;
203
+
204
+ if (this.state.width !== currentWidth) {
205
+ this.setState({ width: currentWidth });
206
+ }
207
+ if (this.state.height !== currentHeight) {
208
+ this.setState({ height: currentHeight });
209
+ }
210
+ }
202
211
  };
203
212
 
204
213
  handleResize = debounce(this.resize, 250);
@@ -56,11 +56,22 @@ import { canUseDOM } from './util';
56
56
  * );
57
57
  * }
58
58
  *
59
+ * Example 3 - With debounced method passed in:
60
+ *
61
+ * public componentDidMount() {
62
+ * this.observer = getResizeObserver(this.inputRef.current, debounce(this.handleResize, 250), false);
63
+ * }
64
+ *
59
65
  * @param {Element} containerRefElement The container reference to observe
60
66
  * @param {Function} handleResize The function to call for resize events
67
+ * @param {boolean} useRequestAnimationFrame Whether to pass the handleResize function as a callback to requestAnimationFrame. Pass in false when the function passed in is debounced. Defaults to true.
61
68
  * @return {Function} The function used to unobserve resize events
62
69
  */
63
- export const getResizeObserver = (containerRefElement: Element, handleResize: () => void) => {
70
+ export const getResizeObserver = (
71
+ containerRefElement: Element,
72
+ handleResize: () => void,
73
+ useRequestAnimationFrame: boolean = true
74
+ ) => {
64
75
  let unobserve: any;
65
76
 
66
77
  if (canUseDOM) {
@@ -69,11 +80,18 @@ export const getResizeObserver = (containerRefElement: Element, handleResize: ()
69
80
  if (containerRefElement && ResizeObserver) {
70
81
  const resizeObserver = new ResizeObserver((entries: any) => {
71
82
  // Wrap resize function in requestAnimationFrame to avoid "ResizeObserver loop limit exceeded" errors
72
- window.requestAnimationFrame(() => {
83
+ if (useRequestAnimationFrame) {
84
+ window.requestAnimationFrame(() => {
85
+ if (Array.isArray(entries) && entries.length > 0) {
86
+ handleResize();
87
+ }
88
+ });
89
+ // Avoid wrapping function in requestAnimationFrame if the function is debounced
90
+ } else {
73
91
  if (Array.isArray(entries) && entries.length > 0) {
74
92
  handleResize();
75
93
  }
76
- });
94
+ }
77
95
  });
78
96
  resizeObserver.observe(containerRefElement);
79
97
  unobserve = () => resizeObserver.unobserve(containerRefElement);