cogsbox-state 0.5.365 → 0.5.366

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": "cogsbox-state",
3
- "version": "0.5.365",
3
+ "version": "0.5.366",
4
4
  "description": "React state management library with form controls and server sync",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/CogsState.tsx CHANGED
@@ -1916,6 +1916,7 @@ function createProxyHandler<T>(
1916
1916
  if (!container) return;
1917
1917
 
1918
1918
  let intervalId: NodeJS.Timeout | undefined;
1919
+ let scrollTimeoutId: NodeJS.Timeout | undefined;
1919
1920
 
1920
1921
  if (
1921
1922
  status === "WAITING_FOR_ARRAY" &&
@@ -1962,9 +1963,7 @@ function createProxyHandler<T>(
1962
1963
  behavior: scrollBehavior,
1963
1964
  });
1964
1965
 
1965
- // After scrolling, we are locked at the bottom.
1966
- // Use a timeout to wait for the animation to finish.
1967
- const timeoutId = setTimeout(
1966
+ scrollTimeoutId = setTimeout(
1968
1967
  () => {
1969
1968
  console.log(
1970
1969
  "ACTION: Scroll finished. -> LOCKED_AT_BOTTOM"
@@ -1973,12 +1972,18 @@ function createProxyHandler<T>(
1973
1972
  },
1974
1973
  scrollBehavior === "smooth" ? 500 : 50
1975
1974
  );
1976
-
1977
- return () => clearTimeout(timeoutId);
1978
1975
  }
1979
1976
 
1977
+ // THE FIX: This cleanup runs whenever the state changes, killing any active timers.
1980
1978
  return () => {
1981
- if (intervalId) clearInterval(intervalId);
1979
+ if (intervalId) {
1980
+ console.log("CLEANUP: Clearing measurement loop timer.");
1981
+ clearInterval(intervalId);
1982
+ }
1983
+ if (scrollTimeoutId) {
1984
+ console.log("CLEANUP: Clearing scroll-end timer.");
1985
+ clearTimeout(scrollTimeoutId);
1986
+ }
1982
1987
  };
1983
1988
  }, [status, totalCount, positions]);
1984
1989