cogsbox-state 0.5.370 → 0.5.371

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.370",
3
+ "version": "0.5.371",
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
@@ -1817,6 +1817,7 @@ function createProxyHandler<T>(
1817
1817
  | "LOCKED_AT_BOTTOM"
1818
1818
  | "IDLE_NOT_AT_BOTTOM";
1819
1819
 
1820
+ const shouldNotScroll = useRef(false);
1820
1821
  const containerRef = useRef<HTMLDivElement | null>(null);
1821
1822
  const [range, setRange] = useState({
1822
1823
  startIndex: 0,
@@ -1954,7 +1955,10 @@ function createProxyHandler<T>(
1954
1955
  setStatus("SCROLLING_TO_BOTTOM");
1955
1956
  }
1956
1957
  }, 100);
1957
- } else if (status === "SCROLLING_TO_BOTTOM") {
1958
+ } else if (
1959
+ status === "SCROLLING_TO_BOTTOM" &&
1960
+ !shouldNotScroll.current
1961
+ ) {
1958
1962
  console.log(
1959
1963
  "ACTION (SCROLLING_TO_BOTTOM): Executing scroll."
1960
1964
  );
@@ -1972,6 +1976,7 @@ function createProxyHandler<T>(
1972
1976
  console.log(
1973
1977
  "ACTION (SCROLLING_TO_BOTTOM): Scroll finished -> LOCKED_AT_BOTTOM"
1974
1978
  );
1979
+ shouldNotScroll.current = false;
1975
1980
  setStatus("LOCKED_AT_BOTTOM");
1976
1981
  },
1977
1982
  scrollBehavior === "smooth" ? 500 : 50
@@ -2005,6 +2010,7 @@ function createProxyHandler<T>(
2005
2010
  console.log(
2006
2011
  "USER ACTION: Scrolled up -> IDLE_NOT_AT_BOTTOM"
2007
2012
  );
2013
+ shouldNotScroll.current = true;
2008
2014
  setStatus("IDLE_NOT_AT_BOTTOM");
2009
2015
  }
2010
2016
  }