Escape key clears search highlights in documents (#11847)

When navigating to a document from search results, the search term is
highlighted via FindAndReplace but the popover is not open, so there was
no way to dismiss the highlights. This adds an Escape key binding to the
FindAndReplace extension that clears highlights when active.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom MoorandClaude Opus 4.6 authored and GitHub committed 2026-03-22 12:21:34 -04:00
1 parent 5691ea5ae3
commit ac1f68a447
1 file changed
+23
+23
View File
@@ -29,6 +29,29 @@ export default class FindAndReplaceExtension extends Extension {
};
}
keys(): Record<string, Command> {
return {
Escape: (state, dispatch) => {
if (!this.searchTerm) {
return false;
}
const params = new URLSearchParams(window.location.search);
if (params.has("q")) {
params.delete("q");
const search = params.toString();
window.history.replaceState(
window.history.state,
"",
window.location.pathname + (search ? `?${search}` : "")
);
}
return this.clear()(state, dispatch);
},
};
}
public commands() {
return {
/**