From ad23fbba9f83b884d99cb4e4a90a28c5dae18bea Mon Sep 17 00:00:00 2001 From: Wanten Date: Tue, 9 Jun 2026 23:44:10 +0800 Subject: [PATCH] fix(reader): dismiss annotation popup when selection clears (#4483) --- apps/readest-app/src/app/reader/hooks/useTextSelector.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/readest-app/src/app/reader/hooks/useTextSelector.ts b/apps/readest-app/src/app/reader/hooks/useTextSelector.ts index 9c8b84f3..404a9cc9 100644 --- a/apps/readest-app/src/app/reader/hooks/useTextSelector.ts +++ b/apps/readest-app/src/app/reader/hooks/useTextSelector.ts @@ -185,10 +185,11 @@ export const useTextSelector = ( // selectionchange for touch/pen input to pick up native text selections. const isAndroid = osPlatform === 'android' && appService?.isAndroidApp; const isTouchInput = lastPointerType.current === 'touch' || lastPointerType.current === 'pen'; - if (!isAndroid && !isTouchInput) return; const sel = doc.getSelection() as Selection; if (isValidSelection(sel)) { + // On desktop with mouse, defer to pointerup for valid selections. + if (!isAndroid && !isTouchInput) return; if (selectionPosition.current === null) { // Save the absolute container scroll, not `renderer.start` — the // latter is section-relative, so restoring it as `containerPosition` @@ -198,6 +199,12 @@ export const useTextSelector = ( } makeSelection(sel, index, false); } else { + // Selection cleared (e.g. clicking outside the selection). + // Dismiss immediately on all platforms. + if (isTextSelected.current) { + handleDismissPopup(); + isTextSelected.current = false; + } selectionPosition.current = null; } };