From 4f35c360549e8b9237ced201dc19b4bfa644d7bd Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Sun, 27 Mar 2022 23:43:24 +0800 Subject: [PATCH] fix: reposition toggle sidebar button into view on window height reduce --- src/components/ToggleShowButton.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ToggleShowButton.tsx b/src/components/ToggleShowButton.tsx index fcd929e..c1ccf0b 100644 --- a/src/components/ToggleShowButton.tsx +++ b/src/components/ToggleShowButton.tsx @@ -37,11 +37,14 @@ export function ToggleShowButton({ error, className, onClick, onHover }: Props) [distance], ) + // reposition on window height change, but ignores distance change React.useEffect(() => { if (ref.current) { ref.current.style.top = distance + 'px' } - }, []) + }, [height]) + + // And this repositions on drag const { onPointerDown } = useResizeHandler( [distance, distance], ([, y]) => {