cogsbox-state 0.5.317 → 0.5.318

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.317",
3
+ "version": "0.5.318",
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
@@ -1966,29 +1966,32 @@ function createProxyHandler<T>(
1966
1966
  passive: true,
1967
1967
  });
1968
1968
 
1969
- // For stick to bottom: first jump to approximate bottom position
1969
+ // For stick to bottom: check conditions without triggering re-renders
1970
1970
  if (
1971
1971
  stickToBottom &&
1972
1972
  !hasScrolledToBottomRef.current &&
1973
1973
  totalCount > 0
1974
1974
  ) {
1975
- if (visibleMeasured || range.endIndex === totalCount) {
1976
- // If we're showing the last items OR current visible items are measured
1975
+ // Check current range without dependency
1976
+ const currentRange = range;
1977
+ const atEnd = currentRange.endIndex >= totalCount - 5; // Close to end
1978
+
1979
+ if (atEnd) {
1977
1980
  console.log(
1978
- `[VirtualView] Scrolling to bottom - visible measured: ${visibleMeasured}, at end: ${range.endIndex === totalCount}`
1981
+ `[VirtualView] At end of list, scrolling to bottom`
1979
1982
  );
1980
1983
  hasScrolledToBottomRef.current = true;
1981
1984
 
1982
- // Use setTimeout to ensure DOM updates are complete
1983
1985
  setTimeout(() => {
1986
+ const scrollTarget = container.scrollHeight + 1000;
1984
1987
  container.scrollTo({
1985
- top: container.scrollHeight + 1000,
1988
+ top: scrollTarget,
1986
1989
  behavior: "auto",
1987
1990
  });
1988
1991
  isLockedToBottomRef.current = true;
1989
- }, 0);
1992
+ }, 50);
1990
1993
  } else {
1991
- // Jump close to the bottom to trigger rendering of bottom items
1994
+ // Jump close to the bottom
1992
1995
  console.log(
1993
1996
  `[VirtualView] Jumping near bottom to trigger measurements`
1994
1997
  );
@@ -2008,13 +2011,7 @@ function createProxyHandler<T>(
2008
2011
  return () => {
2009
2012
  container.removeEventListener("scroll", handleUserScroll);
2010
2013
  };
2011
- }, [
2012
- totalCount,
2013
- positions,
2014
- stickToBottom,
2015
- visibleMeasured,
2016
- range.endIndex,
2017
- ]);
2014
+ }, [totalCount, positions, stickToBottom]); // Removed visibleMeasured and range.endIndex
2018
2015
 
2019
2016
  const scrollToBottom = useCallback(
2020
2017
  (behavior: ScrollBehavior = "smooth") => {