cogsbox-state 0.5.358 → 0.5.359
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/dist/CogsState.jsx +513 -509
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +15 -3
package/package.json
CHANGED
package/src/CogsState.tsx
CHANGED
|
@@ -1808,7 +1808,7 @@ function createProxyHandler<T>(
|
|
|
1808
1808
|
stickToBottom = false,
|
|
1809
1809
|
dependencies = [],
|
|
1810
1810
|
} = options;
|
|
1811
|
-
|
|
1811
|
+
const [instanceKey, setInstanceKey] = useState(0);
|
|
1812
1812
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
1813
1813
|
const [range, setRange] = useState({
|
|
1814
1814
|
startIndex: 0,
|
|
@@ -1993,8 +1993,20 @@ function createProxyHandler<T>(
|
|
|
1993
1993
|
|
|
1994
1994
|
return () =>
|
|
1995
1995
|
container.removeEventListener("scroll", handleUserScroll);
|
|
1996
|
-
}, [totalCount, positions
|
|
1997
|
-
|
|
1996
|
+
}, [totalCount, positions]);
|
|
1997
|
+
useEffect(() => {
|
|
1998
|
+
console.log(
|
|
1999
|
+
"DEPENDENCY CHANGE: Resetting scroll lock and scrolling to bottom."
|
|
2000
|
+
);
|
|
2001
|
+
if (containerRef.current) {
|
|
2002
|
+
// Reset the lock so the main effect can take over on the next data load.
|
|
2003
|
+
isLockedToBottomRef.current = stickToBottom;
|
|
2004
|
+
// Scroll to the top to show the loading state for the new chat.
|
|
2005
|
+
containerRef.current.scrollTop = 0;
|
|
2006
|
+
// Reset the range
|
|
2007
|
+
setRange({ startIndex: 0, endIndex: 10 });
|
|
2008
|
+
}
|
|
2009
|
+
}, dependencies);
|
|
1998
2010
|
const scrollToBottom = useCallback(
|
|
1999
2011
|
(behavior: ScrollBehavior = "smooth") => {
|
|
2000
2012
|
if (containerRef.current) {
|