fix(reader): show selection popup below text on Android to avoid native action bar conflict#3398
Open
croakingtoad wants to merge 2 commits into
Open
Conversation
On touch devices the popup now always appears below the selection, avoiding overlap with Android's native copy/paste action bar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tection Iframe document event listeners run outside Angular's Zone.js, so the popup state was being set but Angular never ran change detection — the popup only appeared after an unrelated Angular interaction (scroll, tap). Wrapping the text-selected emission in ngZone.run() triggers immediate change detection so the popup renders at the same time as the selection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Android, the BookLore text selection popup was broken in two ways:
1. Angular Zone.js — popup state updated but view never rendered
The iframe's
document.addEventListenercallbacks run outside Angular's Zone.js. This meant that wheneventSubject.next({ type: 'text-selected' })fired after a text selection, Angular had no knowledge of the state change and never ran change detection. The popup was effectively set to visible internally, but the DOM never updated.The symptom: the popup would only appear after an unrelated Angular interaction (e.g. scrolling the page), which happened to trigger change detection as a side effect.
Fix: Inject
NgZoneintoReaderEventServiceand wrap thetext-selectedemission inthis.ngZone.run(() => { ... }), forcing Angular to run change detection immediately when a selection is made.2. Popup position — conflicting with Android's native copy/paste action bar
On Android, the OS-level text selection action bar (Copy / Paste / Select All etc.) always appears at the top of the screen above the selection. The BookLore popup was also positioning itself above the selection by default, causing the two to overlap — Android's bar would cover the BookLore popup entirely.
Fix: On touch devices, always show the BookLore popup below the selected text instead of above it. This keeps Android's native bar at the top and the BookLore highlight/annotate popup below the selection where it's fully visible.
Changes
core/event.service.ts— injectNgZone, wraptext-selectedemission inngZone.run()core/event.service.ts— detect touch device and forceshowBelow = trueon mobileTesting
Tested on Android via PWA (Chrome). After these fixes:
Platform
These changes are Android/touch-device specific. Desktop (mouse) behavior is unaffected — the
isMobilecheck ensures the below-positioning only applies on touch devices, and thengZone.run()fix is a correctness fix that benefits all platforms.