cogsbox-state 0.5.407 → 0.5.408

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.407",
3
+ "version": "0.5.408",
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
@@ -1803,10 +1803,6 @@ function createProxyHandler<T>(
1803
1803
  return selectedIndex ?? -1;
1804
1804
  };
1805
1805
  }
1806
- // Simplified useVirtualView approach
1807
- // Optimal approach - replace the useVirtualView implementation
1808
- // Complete useVirtualView implementation with comprehensive logging
1809
- // Complete fixed useVirtualView implementation
1810
1806
  // Complete fixed useVirtualView implementation
1811
1807
  if (prop === "useVirtualView") {
1812
1808
  return (
@@ -1929,20 +1925,27 @@ function createProxyHandler<T>(
1929
1925
  const { scrollTop, scrollHeight, clientHeight } = container;
1930
1926
  const currentBottom = scrollTop + clientHeight;
1931
1927
  const actualBottom = scrollHeight;
1932
- const isAtBottom = actualBottom - currentBottom < 5;
1928
+ const isAtBottom = actualBottom - currentBottom < 50; // Increased tolerance
1933
1929
 
1934
1930
  if (isAtBottom || attempts >= maxAttempts) {
1935
1931
  clearInterval(scrollToBottomIntervalRef.current!);
1936
1932
  scrollToBottomIntervalRef.current = null;
1933
+
1934
+ // Do one final scroll to ensure we're truly at bottom
1935
+ if (
1936
+ isAtBottom &&
1937
+ container.scrollTop <
1938
+ container.scrollHeight - container.clientHeight
1939
+ ) {
1940
+ container.scrollTop = container.scrollHeight;
1941
+ }
1937
1942
  } else {
1938
- // Set flag before scrolling
1939
- isProgrammaticScrollRef.current = true;
1940
- container.scrollTop = container.scrollHeight;
1941
-
1942
- // Reset flag after a short delay
1943
- setTimeout(() => {
1944
- isProgrammaticScrollRef.current = false;
1945
- }, 50);
1943
+ // Only scroll if we're not already scrolling there
1944
+ const targetScroll =
1945
+ container.scrollHeight - container.clientHeight;
1946
+ if (Math.abs(container.scrollTop - targetScroll) > 1) {
1947
+ container.scrollTop = container.scrollHeight;
1948
+ }
1946
1949
  }
1947
1950
  }, 100);
1948
1951
 
@@ -1967,15 +1970,17 @@ function createProxyHandler<T>(
1967
1970
  }
1968
1971
 
1969
1972
  // This is a real user scroll
1973
+ const { scrollTop, scrollHeight, clientHeight } = container;
1974
+ const distanceFromBottom =
1975
+ scrollHeight - scrollTop - clientHeight;
1976
+ const isAtBottom = distanceFromBottom < 50; // Increased tolerance
1977
+
1978
+ // Stop any auto-scrolling if user scrolls
1970
1979
  if (scrollToBottomIntervalRef.current) {
1971
1980
  clearInterval(scrollToBottomIntervalRef.current);
1972
1981
  scrollToBottomIntervalRef.current = null;
1973
1982
  }
1974
1983
 
1975
- const { scrollTop, scrollHeight, clientHeight } = container;
1976
- const isAtBottom =
1977
- scrollHeight - scrollTop - clientHeight < 10;
1978
-
1979
1984
  // Only update this for real user scrolls
1980
1985
  shouldStickToBottomRef.current = isAtBottom;
1981
1986