From 3b639e27833afae5d862e50cfd509ea379207e23 Mon Sep 17 00:00:00 2001 From: Gigi Date: Tue, 14 Oct 2025 00:03:19 +0200 Subject: [PATCH] feat(highlights): clear browser selection immediately after creating highlight - Add window.getSelection().removeAllRanges() after highlight creation - Ensures DOM can update immediately without selection interference - Improves perceived responsiveness of highlight creation --- src/hooks/useHighlightCreation.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hooks/useHighlightCreation.ts b/src/hooks/useHighlightCreation.ts index b93cfde2..9c9c5b86 100644 --- a/src/hooks/useHighlightCreation.ts +++ b/src/hooks/useHighlightCreation.ts @@ -77,6 +77,12 @@ export const useHighlightCreation = ({ publishedRelays: newHighlight.publishedRelays }) + // Clear the browser's text selection immediately to allow DOM update + const selection = window.getSelection() + if (selection) { + selection.removeAllRanges() + } + highlightButtonRef.current?.clearSelection() onHighlightCreated(newHighlight) } catch (error) {