fix(reader): close the highlight popover on outside clicks in the book
Clicks on reader chrome already dismissed the selection popover via the host-document outside-click handler, but clicks inside the book happen in content iframes whose events never bubble to the host document — the host handler never sees them. The only iframe-side dismissal ran through the selection tracker's collapsed check, which hides the popover solely in create mode: once the popover was open in EDIT mode (clicked a highlight, writing a note), clicking anywhere in the book did nothing and Esc was the only way out. Each content iframe now gets a pointerdown listener that dismisses the popover in any mode. Clicking a painted highlight still opens the edit popover: this hides first, then foliate's show-annotation re-opens it.
This commit is contained in:
@@ -744,6 +744,21 @@ document.addEventListener("alpine:init", () => {
|
||||
() => setTimeout(checkSelection, 0),
|
||||
{ passive: true },
|
||||
);
|
||||
// Clicks in the book dismiss the popover in ANY mode: iframe
|
||||
// events never bubble to the host document (so the host
|
||||
// outside-click dismiss never sees them), and the collapsed
|
||||
// check above only covers create mode — edit mode had no
|
||||
// outside-click path at all, leaving Esc as the only way out.
|
||||
// Clicking a painted highlight still works: this hides, then
|
||||
// foliate's show-annotation re-opens it in edit mode.
|
||||
doc.addEventListener(
|
||||
"pointerdown",
|
||||
() => {
|
||||
if (this.selectionPopover.open)
|
||||
this.hideSelectionPopover();
|
||||
},
|
||||
{ passive: true },
|
||||
);
|
||||
doc.addEventListener(
|
||||
"keyup",
|
||||
(ev: KeyboardEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user