fix(finder): open from inputs and find milestones by cue

Two defects surfaced while reviewing the feature.

The search shortcut was dead while any input had focus. The hotkey hook
skips input elements by default, so the shortcut did nothing while
editing an entry title, which is exactly when a user reaches for it.
Opt out of that behaviour and drop the local handler that partially
worked around it, so a single binding both opens and closes.

Milestones were skipped by the cue search even though they carry a cue
and display it in the rundown, so filtering by cue could never find one.
They are already covered by the title search.

Adds e2e coverage for both, and fires the shortcut from a focused input
in the existing keyboard test so the first defect stays fixed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DzALEq9gGWwFmwTdgAiFcY
This commit is contained in:
Claude
2026-08-18 11:55:14 +00:00
parent f34ce5bc3d
commit 671df541ef
4 changed files with 67 additions and 22 deletions
@@ -8,8 +8,12 @@ export default memo(FinderPlacement);
function FinderPlacement() {
const [isOpen, handler] = useDisclosure();
// the finder handles its own dismissal: Escape is handled by the dialog, mod + f by the search input
useHotkeys([['mod + f', handler.toggle, { preventDefault: true }]]);
/**
* The empty tagsToIgnore is significant: by default the hook skips input elements,
* which would make the shortcut dead while editing an entry, and while typing in the
* finder itself. Escape is handled by the dialog.
*/
useHotkeys([['mod + f', handler.toggle, { preventDefault: true }]], []);
if (isOpen) {
return <Finder isOpen={isOpen} onClose={handler.close} />;
@@ -39,16 +39,6 @@ export default function Finder({ isOpen, onClose }: FinderProps) {
}, [activeEntry?.id]);
const navigate = (event: KeyboardEvent<HTMLDivElement>) => {
/**
* Mantine ignores hotkeys while an input is focused, so the global toggle
* cannot close the finder once the user is typing
*/
if ((event.metaKey || event.ctrlKey) && event.key === 'f') {
event.preventDefault();
onClose();
return;
}
// all operations need results
if (results.length === 0) {
return;
@@ -116,34 +116,48 @@ export default function useFinder() {
return { results, error: null };
}
/** Returns maxResults of OntimeEvents that match the cue field */
/** Returns maxResults of entries which carry a cue and match the cue field */
function searchByCue(searchString: string) {
// indexes exposed to the UI are 1-based
let eventIndex = 1;
// limit amount of results we show
let remaining = maxResults;
const results: FilterableEvent[] = [];
const results: FilterableEntry[] = [];
for (let i = 0; i < data.length; i++) {
if (remaining <= 0) {
break;
}
const event = data[i];
if (isOntimeEvent(event)) {
if (event.cue.toLowerCase().includes(searchString)) {
const entry = data[i];
if (isOntimeEvent(entry)) {
if (entry.cue.toLowerCase().includes(searchString)) {
remaining--;
results.push({
type: SupportedEntry.Event,
id: event.id,
id: entry.id,
index: i,
eventIndex,
title: event.title,
cue: event.cue,
colour: event.colour,
parent: event.parent,
title: entry.title,
cue: entry.cue,
colour: entry.colour,
parent: entry.parent,
} satisfies FilterableEvent);
}
eventIndex++;
} else if (isOntimeMilestone(entry)) {
// milestones carry a cue and show it in the rundown, so they belong in a cue search
if (entry.cue.toLowerCase().includes(searchString)) {
remaining--;
results.push({
type: SupportedEntry.Milestone,
id: entry.id,
index: i,
title: entry.title,
cue: entry.cue,
colour: entry.colour,
parent: entry.parent,
} satisfies FilterableMilestone);
}
}
}
return { results, error: null };