From 86b06a1075ac1798a5a07f29fb904e8c64dd5418 Mon Sep 17 00:00:00 2001 From: Ramon Mi Date: Sat, 21 Mar 2026 20:15:06 +0800 Subject: [PATCH] fix(PDF): anchor edit-page-number popup to current annotation label --- src/common/reader.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common/reader.js b/src/common/reader.js index 9ffbc0b8e..d02e76286 100644 --- a/src/common/reader.js +++ b/src/common/reader.js @@ -2116,8 +2116,15 @@ class Reader { let currentAnnotation = this._annotationManager._getAnnotationByID(id); let selectedAnnotations = this._annotationManager._annotations.filter(x => selectedIDs.includes(x.id)); let allAnnotations = this._annotationManager._annotations; - // Get target rect from preview component in the sidebar or a view popup - let labelNode = document.querySelector(`[data-sidebar-annotation-id="${id}"] header .label, .view-popup header .label`); + // Get target rect from the currently visible source: sidebar annotation item + // (when annotations sidebar is active) or the view annotation popup label. + let labelNode; + if (this._state.sidebarOpen && this._state.sidebarView === 'annotations') { + labelNode = document.querySelector(`[data-sidebar-annotation-id="${id}"] header .label`); + } + else { + labelNode = document.querySelector('.annotation-popup header .label'); + } let { left, top, right, bottom } = labelNode.getBoundingClientRect(); let rect = [left, top, right, bottom]; this._updateState({ labelPopup: { currentAnnotation, selectedAnnotations, allAnnotations, rect, selectedIDs, pageLabels } });