From af46d6d75960f993a536418664b348652bed7792 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 19 Aug 2026 05:00:11 +0000 Subject: [PATCH] refactor(finder): drop the pointer movement guard The guard skipped a pointer move whose coordinates matched the previous one, on the reasoning that the list scrolling under a still cursor would otherwise pull the selection away from the keyboard. Measuring it does not support that. With a list of nineteen results in a viewport too short to hold them, and the cursor parked on a row, neither arrowing through the results nor scrolling the wheel delivers a single pointer move to any row, and the selection lands exactly where the keyboard left it. Removing the guard reproduces both results unchanged, and hovering still selects. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01DzALEq9gGWwFmwTdgAiFcY --- apps/client/src/views/editor/finder/Finder.tsx | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/apps/client/src/views/editor/finder/Finder.tsx b/apps/client/src/views/editor/finder/Finder.tsx index 80390e705..e5e4c37fb 100644 --- a/apps/client/src/views/editor/finder/Finder.tsx +++ b/apps/client/src/views/editor/finder/Finder.tsx @@ -1,5 +1,5 @@ -import { EntryId, MaybeString } from 'ontime-types'; -import { KeyboardEvent, PointerEvent, useDeferredValue, useEffect, useRef, useState } from 'react'; +import { MaybeString } from 'ontime-types'; +import { KeyboardEvent, useDeferredValue, useEffect, useRef, useState } from 'react'; import ToggleButton from '../../../common/components/buttons/ToggleButton'; import Input from '../../../common/components/input/input/Input'; @@ -29,7 +29,6 @@ export default function Finder({ isOpen, onClose }: FinderProps) { const inputRef = useRef(null); const activeRef = useRef(null); - const lastPointer = useRef({ x: -1, y: -1 }); /** * We track the selection by ID so that it survives the result list changing under us: @@ -79,16 +78,6 @@ export default function Finder({ isOpen, onClose }: FinderProps) { onClose(); }; - const handlePointerMove = (event: PointerEvent, id: EntryId) => { - // scrolling the list under a stationary cursor also fires a move event, which would - // pull the selection away from wherever the keyboard navigation left it - if (event.clientX === lastPointer.current.x && event.clientY === lastPointer.current.y) { - return; - } - lastPointer.current = { x: event.clientX, y: event.clientY }; - setSelectedId(id); - }; - /** Scopes the search to a single field, or back to all fields when tapped again */ const handleFilter = (filterKey: string) => { setFilter((previous) => (previous === filterKey ? null : filterKey)); @@ -143,7 +132,7 @@ export default function Finder({ isOpen, onClose }: FinderProps) { data-testid='finder-result' data-selected={isSelected} onClick={() => submit(entry)} - onPointerMove={(event) => handlePointerMove(event, entry.id)} + onPointerMove={() => setSelectedId(entry.id)} >