From ac1f68a44709ea3dc1b975415fb48bbb2c3acb16 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 22 Mar 2026 12:21:34 -0400 Subject: [PATCH] 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 --- app/editor/extensions/FindAndReplace.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/editor/extensions/FindAndReplace.tsx b/app/editor/extensions/FindAndReplace.tsx index 884785042b..50a4b2e277 100644 --- a/app/editor/extensions/FindAndReplace.tsx +++ b/app/editor/extensions/FindAndReplace.tsx @@ -29,6 +29,29 @@ export default class FindAndReplaceExtension extends Extension { }; } + keys(): Record { + 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 { /**