diff --git a/src/apps/officer-web/Screens/Dashboard/Layout/Dock.tsx b/src/apps/officer-web/Screens/Dashboard/Layout/Dock.tsx index 8a0dfc7a..8aebb6bc 100644 --- a/src/apps/officer-web/Screens/Dashboard/Layout/Dock.tsx +++ b/src/apps/officer-web/Screens/Dashboard/Layout/Dock.tsx @@ -37,17 +37,23 @@ export const Dock = ({ items, className }: DockProps) => { const location = useLocation(); const { current } = useMusicPlayer(); const musicDockPresent = !!current; + // Read the latest value inside the (once-registered) mousemove handler, so it reacts to the music + // dock appearing/disappearing without re-binding the listener. + const musicPresentRef = useRef(musicDockPresent); + musicPresentRef.current = musicDockPresent; const isActive = (to: string) => (to === '/' ? location.pathname === '/' : location.pathname.startsWith(to)); useEffect(() => { const handleMouseMove = (ev: MouseEvent) => { const distFromBottom = window.innerHeight - ev.clientY; - setVisible((prev) => { - if (!prev) return distFromBottom <= SHOW_THRESHOLD; - return distFromBottom <= HIDE_THRESHOLD; - }); - if (distFromBottom <= HIDE_THRESHOLD) { + // When the music dock is present the nav dock rides MUSIC_DOCK_HEIGHT higher, so lift the hide/ + // magnify zone by the same amount — otherwise hovering the raised dock counts as past the hide + // threshold and it slides away under the cursor. The reveal trigger stays at the bottom edge. + const lift = musicPresentRef.current ? MUSIC_DOCK_HEIGHT : 0; + const hideAt = HIDE_THRESHOLD + lift; + setVisible((prev) => (prev ? distFromBottom <= hideAt : distFromBottom <= SHOW_THRESHOLD)); + if (distFromBottom <= hideAt) { const rect = dockRef.current?.getBoundingClientRect(); if (rect) setMouseX(ev.clientX - rect.left); } else {