@@ -54,8 +54,8 @@ def add_hooks(self) -> list[str | Var]:
5454 ref_name = self .get_ref ()
5555 unique_id = ref_name
5656 return [
57- "const wasNearBottom = useRef(false);" ,
58- "const hadScrollbar = useRef(false);" ,
57+ f "const wasNearBottom_ { unique_id } = useRef(false);" ,
58+ f "const hadScrollbar_ { unique_id } = useRef(false);" ,
5959 f"""
6060const checkIfNearBottom_{ unique_id } = () => {{
6161 if (!{ ref_name } .current) return;
@@ -65,10 +65,10 @@ def add_hooks(self) -> list[str | Var]:
6565
6666 const distanceFromBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
6767
68- wasNearBottom .current = distanceFromBottom <= nearBottomThreshold;
68+ wasNearBottom_ { unique_id } .current = distanceFromBottom <= nearBottomThreshold;
6969
7070 // Track if container had a scrollbar
71- hadScrollbar .current = container.scrollHeight > container.clientHeight;
71+ hadScrollbar_ { unique_id } .current = container.scrollHeight > container.clientHeight;
7272}};
7373""" ,
7474 f"""
@@ -81,12 +81,12 @@ def add_hooks(self) -> list[str | Var]:
8181 // Scroll if:
8282 // 1. User was near bottom, OR
8383 // 2. Container didn't have scrollbar before but does now
84- if (wasNearBottom .current || (!hadScrollbar .current && hasScrollbarNow)) {{
84+ if (wasNearBottom_ { unique_id } .current || (!hadScrollbar_ { unique_id } .current && hasScrollbarNow)) {{
8585 container.scrollTop = container.scrollHeight;
8686 }}
8787
8888 // Update scrollbar state for next check
89- hadScrollbar .current = hasScrollbarNow;
89+ hadScrollbar_ { unique_id } .current = hasScrollbarNow;
9090}};
9191""" ,
9292 f"""
0 commit comments