@trackunit/react-components 1.10.14 → 1.10.16

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/index.cjs.js CHANGED
@@ -3803,6 +3803,8 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
3803
3803
  const containerRef = react.useRef(null);
3804
3804
  const listRef = react.useRef(null);
3805
3805
  const rowRefsMap = react.useRef(new Map());
3806
+ const virtualizerRef = react.useRef(null);
3807
+ const hasMeasuredOnMount = react.useRef(false);
3806
3808
  // Resolve loading indicator once to avoid unnecessary re-renders
3807
3809
  const resolvedLoadingIndicator = react.useMemo(() => getResolvedLoadingIndicator(loadingIndicator), [loadingIndicator]);
3808
3810
  // Calculate total count including header
@@ -3906,13 +3908,16 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
3906
3908
  onChange?.(instance);
3907
3909
  },
3908
3910
  });
3909
- // Measure the list on mount
3911
+ // Keep ref updated with latest virtualizer instance
3912
+ react.useEffect(() => {
3913
+ virtualizerRef.current = virtualizer;
3914
+ }, [virtualizer]);
3915
+ // Measure the list on mount only (not on subsequent virtualizer updates)
3910
3916
  react.useLayoutEffect(() => {
3911
- // Automatically measure if header is present, or if explicitly requested
3912
- virtualizer.measure();
3913
- // This is straight out of the TanStack Virtual docs, so we'll trust it.
3914
- // eslint-disable-next-line react-hooks/react-compiler
3915
- // eslint-disable-next-line react-hooks/exhaustive-deps
3917
+ if (!hasMeasuredOnMount.current) {
3918
+ virtualizerRef.current?.measure();
3919
+ hasMeasuredOnMount.current = true;
3920
+ }
3916
3921
  }, []);
3917
3922
  // Scroll to top when total count changes (filtering applied)
3918
3923
  // Don't scroll when just loading more items (infinite scroll - total stays the same)
package/index.esm.js CHANGED
@@ -3801,6 +3801,8 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
3801
3801
  const containerRef = useRef(null);
3802
3802
  const listRef = useRef(null);
3803
3803
  const rowRefsMap = useRef(new Map());
3804
+ const virtualizerRef = useRef(null);
3805
+ const hasMeasuredOnMount = useRef(false);
3804
3806
  // Resolve loading indicator once to avoid unnecessary re-renders
3805
3807
  const resolvedLoadingIndicator = useMemo(() => getResolvedLoadingIndicator(loadingIndicator), [loadingIndicator]);
3806
3808
  // Calculate total count including header
@@ -3904,13 +3906,16 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
3904
3906
  onChange?.(instance);
3905
3907
  },
3906
3908
  });
3907
- // Measure the list on mount
3909
+ // Keep ref updated with latest virtualizer instance
3910
+ useEffect(() => {
3911
+ virtualizerRef.current = virtualizer;
3912
+ }, [virtualizer]);
3913
+ // Measure the list on mount only (not on subsequent virtualizer updates)
3908
3914
  useLayoutEffect(() => {
3909
- // Automatically measure if header is present, or if explicitly requested
3910
- virtualizer.measure();
3911
- // This is straight out of the TanStack Virtual docs, so we'll trust it.
3912
- // eslint-disable-next-line react-hooks/react-compiler
3913
- // eslint-disable-next-line react-hooks/exhaustive-deps
3915
+ if (!hasMeasuredOnMount.current) {
3916
+ virtualizerRef.current?.measure();
3917
+ hasMeasuredOnMount.current = true;
3918
+ }
3914
3919
  }, []);
3915
3920
  // Scroll to top when total count changes (filtering applied)
3916
3921
  // Don't scroll when just loading more items (infinite scroll - total stays the same)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "1.10.14",
3
+ "version": "1.10.16",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -16,11 +16,11 @@
16
16
  "@floating-ui/react": "^0.26.25",
17
17
  "string-ts": "^2.0.0",
18
18
  "tailwind-merge": "^2.0.0",
19
- "@trackunit/ui-design-tokens": "1.7.48",
20
- "@trackunit/css-class-variance-utilities": "1.7.48",
21
- "@trackunit/shared-utils": "1.9.48",
22
- "@trackunit/ui-icons": "1.7.49",
23
- "@trackunit/react-test-setup": "1.4.48",
19
+ "@trackunit/ui-design-tokens": "1.7.49",
20
+ "@trackunit/css-class-variance-utilities": "1.7.49",
21
+ "@trackunit/shared-utils": "1.9.49",
22
+ "@trackunit/ui-icons": "1.7.50",
23
+ "@trackunit/react-test-setup": "1.4.49",
24
24
  "@tanstack/react-router": "1.114.29",
25
25
  "es-toolkit": "^1.39.10",
26
26
  "@tanstack/react-virtual": "3.13.12"