From 1cb14edf3fbaf19f5b9ddb4f03caa5c82a37d858 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 9 Jun 2026 22:30:47 -0400 Subject: [PATCH] PR feedback --- app/editor/components/FindAndReplace.tsx | 18 +++++++++++++----- app/editor/extensions/FindAndReplace.tsx | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/editor/components/FindAndReplace.tsx b/app/editor/components/FindAndReplace.tsx index 5c574e60c6..34665d4292 100644 --- a/app/editor/components/FindAndReplace.tsx +++ b/app/editor/components/FindAndReplace.tsx @@ -213,8 +213,7 @@ export default function FindAndReplace({ }, [caseSensitive, editor.commands, searchTerm]); // Searching the document on every keystroke is expensive in long documents – - // it traverses the entire doc and rebuilds highlights – so debounce it to keep - // typing in the input responsive. The input value itself updates immediately. + // it traverses the entire doc and rebuilds highlights – so debounce. const debouncedFind = React.useMemo( () => debounce( @@ -225,7 +224,7 @@ export default function FindAndReplace({ }) => { editor.commands.find(attrs); }, - 100 + 250 ), [editor.commands] ); @@ -355,6 +354,9 @@ export default function FindAndReplace({ } else { onClose(); setShowReplace(false); + // Cancel any pending debounced find so it can't reactivate highlights + // after the search has been cleared. + debouncedFind.cancel(); editor.commands.clearSearch(); } // oxlint-disable-next-line react-hooks/exhaustive-deps @@ -370,7 +372,10 @@ export default function FindAndReplace({ > editor.commands.prevSearchMatch()} + onClick={() => { + debouncedFind.flush(); + editor.commands.prevSearchMatch(); + }} aria-label={t("Previous match")} > @@ -379,7 +384,10 @@ export default function FindAndReplace({ editor.commands.nextSearchMatch()} + onClick={() => { + debouncedFind.flush(); + editor.commands.nextSearchMatch(); + }} aria-label={t("Next match")} > diff --git a/app/editor/extensions/FindAndReplace.tsx b/app/editor/extensions/FindAndReplace.tsx index d24f2314b0..cf30df77a5 100644 --- a/app/editor/extensions/FindAndReplace.tsx +++ b/app/editor/extensions/FindAndReplace.tsx @@ -410,8 +410,8 @@ export default class FindAndReplaceExtension extends Extension