@primer/react 38.47.0-rc.cdd1ab1f0 → 39.0.0-rc.00628b8df

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.
@@ -7,12 +7,10 @@ import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
7
7
  import { FilteredActionListBodyLoader } from "./FilteredActionListLoaders.js";
8
8
  import FilteredActionList_module_css_default from "./FilteredActionList.module.css.js";
9
9
  import Checkbox from "../Checkbox/Checkbox.js";
10
+ import { FilteredActionListLoadingTypes } from "./constants.js";
10
11
  import { ActionListContainerContext } from "../ActionList/ActionListContainerContext.js";
11
12
  import { useAnnouncements } from "./useAnnouncements.js";
12
- import { FilteredActionListLoadingTypes } from "./constants.js";
13
13
  import { useMergedRefs } from "../hooks/useMergedRefs.js";
14
- import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
15
- import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
16
14
  import { FilteredActionListInput } from "./FilteredActionListInput.js";
17
15
  import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
18
16
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -26,7 +24,7 @@ const menuScrollMargins = {
26
24
  endMargin: 8
27
25
  };
28
26
  function FilteredActionList({ loading = false, placeholderText, filterValue: externalFilterValue, loadingType = FilteredActionListLoadingTypes.bodySpinner, onFilterChange, onListContainerRefChanged, onInputRefChanged, items, textInputProps, inputRef: providedInputRef, scrollContainerRef: providedScrollContainerRef, groupMetadata, showItemDividers, message, messageText, className, selectionVariant, announcementsEnabled = true, fullScreenOnNarrow, onSelectAllChange, actionListProps, focusOutBehavior = "wrap", _PrivateFocusManagement = "active-descendant", onActiveDescendantChanged, disableSelectOnHover = false, setInitialFocus = false, focusPrependedElements, scrollBehavior, virtualized = false, ...listProps }) {
29
- var _readScrollContainerR;
27
+ var _scrollContainerRef$c;
30
28
  if (virtualized && groupMetadata !== null && groupMetadata !== void 0 && groupMetadata.length) console.warn("FilteredActionList: `virtualized` has no effect when `groupMetadata` is provided. Grouped lists are rendered without virtualization.");
31
29
  const isVirtualized = virtualized && !(groupMetadata !== null && groupMetadata !== void 0 && groupMetadata.length);
32
30
  const [filterValue, setInternalFilterValue] = useProvidedStateOrCreate(externalFilterValue, void 0, "");
@@ -37,17 +35,10 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
37
35
  }, [onFilterChange, setInternalFilterValue]);
38
36
  const inputAndListContainerRef = useRef(null);
39
37
  const listRef = useRef(null);
40
- const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
41
38
  const scrollContainerRef = useRef(null);
42
39
  const mergedScrollContainerRef = useMergedRefs(scrollContainerRef, providedScrollContainerRef);
43
- const providedOrCreatedScrollContainerRef = useProvidedRefOrCreate(providedScrollContainerRef);
44
- const readScrollContainerRef = mergedRefEnabled ? scrollContainerRef : providedOrCreatedScrollContainerRef;
45
- const appliedScrollContainerRef = mergedRefEnabled ? mergedScrollContainerRef : providedOrCreatedScrollContainerRef;
46
40
  const inputRef = useRef(null);
47
41
  const mergedInputRef = useMergedRefs(inputRef, providedInputRef);
48
- const providedOrCreatedInputRef = useProvidedRefOrCreate(providedInputRef);
49
- const readInputRef = mergedRefEnabled ? inputRef : providedOrCreatedInputRef;
50
- const appliedInputRef = mergedRefEnabled ? mergedInputRef : providedOrCreatedInputRef;
51
42
  const usingRovingTabindex = _PrivateFocusManagement === "roving-tabindex";
52
43
  const [listContainerElement, setListContainerElement] = useState(null);
53
44
  const activeDescendantRef = useRef();
@@ -102,12 +93,12 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
102
93
  onListContainerRefChanged === null || onListContainerRefChanged === void 0 || onListContainerRefChanged(node);
103
94
  }, [onListContainerRefChanged]);
104
95
  useEffect(() => {
105
- onInputRefChanged === null || onInputRefChanged === void 0 || onInputRefChanged(readInputRef);
106
- }, [readInputRef, onInputRefChanged]);
96
+ onInputRefChanged === null || onInputRefChanged === void 0 || onInputRefChanged(inputRef);
97
+ }, [onInputRefChanged]);
107
98
  const DEFAULT_VIRTUAL_ITEM_HEIGHT = 32;
108
99
  const virtualizer = useVirtualizer({
109
100
  count: items.length,
110
- getScrollElement: () => readScrollContainerRef.current,
101
+ getScrollElement: () => scrollContainerRef.current,
111
102
  estimateSize: () => DEFAULT_VIRTUAL_ITEM_HEIGHT,
112
103
  overscan: 10,
113
104
  enabled: isVirtualized,
@@ -141,7 +132,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
141
132
  focusableElementFilter: (element) => {
142
133
  return !(element instanceof HTMLInputElement);
143
134
  },
144
- activeDescendantFocus: readInputRef,
135
+ activeDescendantFocus: inputRef,
145
136
  onActiveDescendantChanged: (current, previous, directlyActivated) => {
146
137
  activeDescendantRef.current = current;
147
138
  if (isVirtualized && current) {
@@ -149,7 +140,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
149
140
  const range = virtualizer.range;
150
141
  if (index !== null && range && (Number(index) < range.startIndex || Number(index) >= range.endIndex)) virtualizer.scrollToIndex(Number(index), { align: "auto" });
151
142
  }
152
- if (current && readScrollContainerRef.current && (directlyActivated || focusPrependedElements)) scrollIntoView(current, readScrollContainerRef.current, {
143
+ if (current && scrollContainerRef.current && (directlyActivated || focusPrependedElements)) scrollIntoView(current, scrollContainerRef.current, {
153
144
  ...menuScrollMargins,
154
145
  behavior: scrollBehavior
155
146
  });
@@ -166,16 +157,11 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
166
157
  isVirtualized
167
158
  ]);
168
159
  useEffect(() => {
169
- if (activeDescendantRef.current && readScrollContainerRef.current) scrollIntoView(activeDescendantRef.current, readScrollContainerRef.current, {
160
+ if (activeDescendantRef.current && scrollContainerRef.current) scrollIntoView(activeDescendantRef.current, scrollContainerRef.current, {
170
161
  ...menuScrollMargins,
171
162
  behavior: scrollBehavior
172
163
  });
173
- }, [
174
- items,
175
- readInputRef,
176
- readScrollContainerRef,
177
- scrollBehavior
178
- ]);
164
+ }, [items, scrollBehavior]);
179
165
  useEffect(() => {
180
166
  if (usingRovingTabindex) {
181
167
  const inputAndListContainerElement = inputAndListContainerRef.current;
@@ -183,7 +169,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
183
169
  const list = listRef.current;
184
170
  if (!list) return;
185
171
  const handleFocusIn = (event) => {
186
- if (event.target === readInputRef.current || list.contains(event.target)) setIsInputFocused(readInputRef.current && readInputRef.current === document.activeElement ? true : false);
172
+ if (event.target === inputRef.current || list.contains(event.target)) setIsInputFocused(inputRef.current && inputRef.current === document.activeElement ? true : false);
187
173
  };
188
174
  inputAndListContainerElement.addEventListener("focusin", handleFocusIn);
189
175
  return () => {
@@ -192,23 +178,18 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
192
178
  }
193
179
  }, [
194
180
  items,
195
- readInputRef,
196
181
  listContainerElement,
197
182
  usingRovingTabindex
198
183
  ]);
199
184
  useEffect(() => {
200
- if (usingRovingTabindex && !loading) setIsInputFocused(readInputRef.current && readInputRef.current === document.activeElement ? true : false);
201
- }, [
202
- loading,
203
- readInputRef,
204
- usingRovingTabindex
205
- ]);
206
- const onInputFocus = useAnnouncements(items, listRef, readInputRef, announcementsEnabled, loading, messageText, _PrivateFocusManagement, filterValue);
207
- useScrollFlash(readScrollContainerRef);
185
+ if (usingRovingTabindex && !loading) setIsInputFocused(inputRef.current && inputRef.current === document.activeElement ? true : false);
186
+ }, [loading, usingRovingTabindex]);
187
+ const onInputFocus = useAnnouncements(items, listRef, inputRef, announcementsEnabled, loading, messageText, _PrivateFocusManagement, filterValue);
188
+ useScrollFlash(scrollContainerRef);
208
189
  const handleSelectAllChange = useCallback((e) => {
209
190
  if (onSelectAllChange) onSelectAllChange(e.target.checked);
210
191
  }, [onSelectAllChange]);
211
- const bodyLoaderHeight = loading && loadingType.appearsInBody ? (_readScrollContainerR = readScrollContainerRef.current) === null || _readScrollContainerR === void 0 ? void 0 : _readScrollContainerR.clientHeight : void 0;
192
+ const bodyLoaderHeight = loading && loadingType.appearsInBody ? (_scrollContainerRef$c = scrollContainerRef.current) === null || _scrollContainerRef$c === void 0 ? void 0 : _scrollContainerRef$c.clientHeight : void 0;
212
193
  const showBodyLoader = bodyLoaderHeight !== void 0;
213
194
  const isListRendered = !showBodyLoader && !message;
214
195
  function getBodyContent() {
@@ -306,7 +287,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
306
287
  "data-component": "FilteredActionList",
307
288
  children: [
308
289
  /* @__PURE__ */ jsx(FilteredActionListInput, {
309
- inputRef: appliedInputRef,
290
+ inputRef: mergedInputRef,
310
291
  onInputFocus,
311
292
  value: filterValue,
312
293
  onInputChange,
@@ -341,7 +322,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
341
322
  })]
342
323
  }),
343
324
  /* @__PURE__ */ jsx("div", {
344
- ref: appliedScrollContainerRef,
325
+ ref: mergedScrollContainerRef,
345
326
  className: FilteredActionList_module_css_default.Container,
346
327
  children: getBodyContent()
347
328
  })
@@ -6,8 +6,6 @@ import { getResponsiveAttributes } from "../internal/utils/getResponsiveAttribut
6
6
  import { areAllValuesTheSame, haveRegularAndWideSameValue } from "../utils/getBreakpointDeclarations.js";
7
7
  import { warning } from "../utils/warning.js";
8
8
  import { useMergedRefs } from "../hooks/useMergedRefs.js";
9
- import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
10
- import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
11
9
  import PageHeader_module_css_default from "./PageHeader.module.css.js";
12
10
  import { isSlot } from "../utils/is-slot.js";
13
11
  import React, { useEffect, useRef } from "react";
@@ -26,15 +24,11 @@ const hiddenOnNarrow = {
26
24
  wide: false
27
25
  };
28
26
  const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
29
- const $ = c(17);
27
+ const $ = c(16);
30
28
  const { children, className, as: t1, "aria-label": ariaLabel, role, hasBorder } = t0;
31
29
  const BaseComponent = t1 === void 0 ? "div" : t1;
32
- const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
33
30
  const rootRef = useRef(null);
34
31
  const mergedRef = useMergedRefs(rootRef, forwardedRef);
35
- const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
36
- const readRef = mergedRefEnabled ? rootRef : providedOrCreatedRef;
37
- const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
38
32
  const hoistChildState = (nodes) => {
39
33
  const result = { hasNavigation: false };
40
34
  for (const child of React.Children.toArray(nodes)) {
@@ -61,12 +55,12 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
61
55
  const isInteractive = _temp;
62
56
  let t2;
63
57
  let t3;
64
- if ($[0] !== children || $[1] !== readRef) {
58
+ if ($[0] !== children) {
65
59
  t2 = function validateInteractiveElementsInTitle() {
66
60
  let hasContextArea = false;
67
61
  let hasLeadingAction = false;
68
- if (!readRef.current || readRef.current.children.length <= 0) return;
69
- const titleArea = Array.from(readRef.current.children).find(_temp2);
62
+ if (!rootRef.current || rootRef.current.children.length <= 0) return;
63
+ const titleArea = Array.from(rootRef.current.children).find(_temp2);
70
64
  if (!titleArea) return;
71
65
  for (const child_1 of React.Children.toArray(children)) {
72
66
  if (/*#__PURE__*/ React.isValidElement(child_1) && (child_1.type === ContextArea || isSlot(child_1, ContextArea))) hasContextArea = true;
@@ -75,31 +69,30 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
75
69
  const hasInteractiveContent = Array.from(titleArea.childNodes).some((child_2) => child_2 instanceof HTMLElement && isInteractive(child_2) || Array.from(child_2.childNodes).some((child_3) => child_3 instanceof HTMLElement && isInteractive(child_3)));
76
70
  warning(hasInteractiveContent && (hasContextArea || hasLeadingAction), "When PageHeader.ContextArea or PageHeader.LeadingAction is present, we recommended not to include any interactive items in the PageHeader.TitleArea to make sure the focus order is logical.");
77
71
  };
78
- t3 = [children, readRef];
72
+ t3 = [children];
79
73
  $[0] = children;
80
- $[1] = readRef;
81
- $[2] = t2;
82
- $[3] = t3;
74
+ $[1] = t2;
75
+ $[2] = t3;
83
76
  } else {
84
- t2 = $[2];
85
- t3 = $[3];
77
+ t2 = $[1];
78
+ t3 = $[2];
86
79
  }
87
80
  useEffect(t2, t3);
88
81
  let t4;
89
- if ($[4] !== className) {
82
+ if ($[3] !== className) {
90
83
  t4 = clsx(PageHeader_module_css_default.PageHeader, className);
91
- $[4] = className;
92
- $[5] = t4;
93
- } else t4 = $[5];
84
+ $[3] = className;
85
+ $[4] = t4;
86
+ } else t4 = $[4];
94
87
  const t5 = "PageHeader";
95
88
  const t6 = hasBorder ? "true" : void 0;
96
89
  const t7 = hasNavigation ? "" : void 0;
97
90
  const t8 = getResponsiveAttributes("title-size-variant", titleVariant);
98
91
  const t9 = getNavHiddenDataAttributes(navigationHidden);
99
92
  let t10;
100
- if ($[6] !== BaseComponent || $[7] !== appliedRef || $[8] !== ariaLabel || $[9] !== children || $[10] !== role || $[11] !== t4 || $[12] !== t6 || $[13] !== t7 || $[14] !== t8 || $[15] !== t9) {
93
+ if ($[5] !== BaseComponent || $[6] !== ariaLabel || $[7] !== children || $[8] !== mergedRef || $[9] !== role || $[10] !== t4 || $[11] !== t6 || $[12] !== t7 || $[13] !== t8 || $[14] !== t9) {
101
94
  t10 = /* @__PURE__ */ jsx(BaseComponent, {
102
- ref: appliedRef,
95
+ ref: mergedRef,
103
96
  className: t4,
104
97
  "data-component": t5,
105
98
  "data-has-border": t6,
@@ -110,18 +103,18 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
110
103
  role,
111
104
  children
112
105
  });
113
- $[6] = BaseComponent;
114
- $[7] = appliedRef;
115
- $[8] = ariaLabel;
116
- $[9] = children;
117
- $[10] = role;
118
- $[11] = t4;
119
- $[12] = t6;
120
- $[13] = t7;
121
- $[14] = t8;
122
- $[15] = t9;
123
- $[16] = t10;
124
- } else t10 = $[16];
106
+ $[5] = BaseComponent;
107
+ $[6] = ariaLabel;
108
+ $[7] = children;
109
+ $[8] = mergedRef;
110
+ $[9] = role;
111
+ $[10] = t4;
112
+ $[11] = t6;
113
+ $[12] = t7;
114
+ $[13] = t8;
115
+ $[14] = t9;
116
+ $[15] = t10;
117
+ } else t10 = $[15];
125
118
  return t10;
126
119
  });
127
120
  const ContextArea = (t0) => {
@@ -303,9 +296,6 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
303
296
  const { children, className, hidden: t1, variant: t2 } = t0;
304
297
  const hidden = t1 === void 0 ? false : t1;
305
298
  const variant = t2 === void 0 ? "medium" : t2;
306
- const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
307
- const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
308
- const appliedRef = mergedRefEnabled ? forwardedRef : providedOrCreatedRef;
309
299
  let t3;
310
300
  if ($[0] !== className) {
311
301
  t3 = clsx(PageHeader_module_css_default.TitleArea, className);
@@ -325,17 +315,17 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
325
315
  $[5] = t5;
326
316
  } else t5 = $[5];
327
317
  let t6;
328
- if ($[6] !== appliedRef || $[7] !== children || $[8] !== t3 || $[9] !== t4 || $[10] !== t5) {
318
+ if ($[6] !== children || $[7] !== forwardedRef || $[8] !== t3 || $[9] !== t4 || $[10] !== t5) {
329
319
  t6 = /* @__PURE__ */ jsx("div", {
330
320
  className: t3,
331
- ref: appliedRef,
321
+ ref: forwardedRef,
332
322
  "data-component": "TitleArea",
333
323
  ...t4,
334
324
  ...t5,
335
325
  children
336
326
  });
337
- $[6] = appliedRef;
338
- $[7] = children;
327
+ $[6] = children;
328
+ $[7] = forwardedRef;
339
329
  $[8] = t3;
340
330
  $[9] = t4;
341
331
  $[10] = t5;
@@ -235,12 +235,12 @@ function usePaneWidth(t0) {
235
235
  t13 = () => {
236
236
  var _paneRef$current3;
237
237
  if (!resizable) return;
238
- let lastViewportWidth = window.innerWidth;
238
+ const viewportState = { lastWidth: window.innerWidth };
239
239
  const syncAll = () => {
240
240
  var _paneRef$current;
241
241
  const currentViewportWidth = window.innerWidth;
242
- const crossedBreakpoint = lastViewportWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT || lastViewportWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT;
243
- lastViewportWidth = currentViewportWidth;
242
+ const crossedBreakpoint = viewportState.lastWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT || viewportState.lastWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT;
243
+ viewportState.lastWidth = currentViewportWidth;
244
244
  if (crossedBreakpoint) maxWidthDiffRef.current = getMaxWidthDiffFromViewport();
245
245
  const actualMax = getMaxPaneWidthRef.current();
246
246
  (_paneRef$current = paneRef.current) === null || _paneRef$current === void 0 || _paneRef$current.style.setProperty("--pane-max-width", `${actualMax}px`);
@@ -275,50 +275,52 @@ function usePaneWidth(t0) {
275
275
  setMaxPaneWidth(initialMax);
276
276
  });
277
277
  if (customMaxWidth !== null && !constrainToViewport) return;
278
- let lastUpdateTime = 0;
279
- let pendingUpdate = false;
280
- let rafId = null;
281
- let debounceId = null;
282
- let isResizing = false;
278
+ const resizeState = {
279
+ lastUpdateTime: 0,
280
+ pendingUpdate: false,
281
+ rafId: null,
282
+ debounceId: null,
283
+ isResizing: false
284
+ };
283
285
  const startResizeOptimizations = () => {
284
286
  var _paneRef$current4, _contentWrapperRef$cu;
285
- if (isResizing) return;
286
- isResizing = true;
287
+ if (resizeState.isResizing) return;
288
+ resizeState.isResizing = true;
287
289
  (_paneRef$current4 = paneRef.current) === null || _paneRef$current4 === void 0 || _paneRef$current4.setAttribute("data-dragging", "true");
288
290
  contentWrapperRef === null || contentWrapperRef === void 0 || (_contentWrapperRef$cu = contentWrapperRef.current) === null || _contentWrapperRef$cu === void 0 || _contentWrapperRef$cu.setAttribute("data-dragging", "true");
289
291
  };
290
292
  const endResizeOptimizations = () => {
291
293
  var _paneRef$current5, _contentWrapperRef$cu2;
292
- if (!isResizing) return;
293
- isResizing = false;
294
+ if (!resizeState.isResizing) return;
295
+ resizeState.isResizing = false;
294
296
  (_paneRef$current5 = paneRef.current) === null || _paneRef$current5 === void 0 || _paneRef$current5.removeAttribute("data-dragging");
295
297
  contentWrapperRef === null || contentWrapperRef === void 0 || (_contentWrapperRef$cu2 = contentWrapperRef.current) === null || _contentWrapperRef$cu2 === void 0 || _contentWrapperRef$cu2.removeAttribute("data-dragging");
296
298
  };
297
299
  const handleResize = () => {
298
300
  startResizeOptimizations();
299
301
  const now = Date.now();
300
- if (now - lastUpdateTime >= 16) {
301
- lastUpdateTime = now;
302
+ if (now - resizeState.lastUpdateTime >= 16) {
303
+ resizeState.lastUpdateTime = now;
302
304
  syncAll();
303
- } else if (!pendingUpdate) {
304
- pendingUpdate = true;
305
- rafId = requestAnimationFrame(() => {
306
- pendingUpdate = false;
307
- rafId = null;
308
- lastUpdateTime = Date.now();
305
+ } else if (!resizeState.pendingUpdate) {
306
+ resizeState.pendingUpdate = true;
307
+ resizeState.rafId = requestAnimationFrame(() => {
308
+ resizeState.pendingUpdate = false;
309
+ resizeState.rafId = null;
310
+ resizeState.lastUpdateTime = Date.now();
309
311
  syncAll();
310
312
  });
311
313
  }
312
- if (debounceId !== null) clearTimeout(debounceId);
313
- debounceId = setTimeout(() => {
314
- debounceId = null;
314
+ if (resizeState.debounceId !== null) clearTimeout(resizeState.debounceId);
315
+ resizeState.debounceId = setTimeout(() => {
316
+ resizeState.debounceId = null;
315
317
  endResizeOptimizations();
316
318
  }, 150);
317
319
  };
318
320
  window.addEventListener("resize", handleResize);
319
321
  return () => {
320
- if (rafId !== null) cancelAnimationFrame(rafId);
321
- if (debounceId !== null) clearTimeout(debounceId);
322
+ if (resizeState.rafId !== null) cancelAnimationFrame(resizeState.rafId);
323
+ if (resizeState.debounceId !== null) clearTimeout(resizeState.debounceId);
322
324
  endResizeOptimizations();
323
325
  window.removeEventListener("resize", handleResize);
324
326
  };