1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Don't close the secondaryToolbar when clicking inside it (PR 18385 follow-up)

When the DOM structure of the viewer was updated in PR 18385 it caused the `secondaryToolbar` to accidentally start closing when clicking inside of it, since the `secondaryToolbar` now reside *under* the `toolbar` in the DOM.

**Steps to reproduce:**
 - Open the viewer.
 - Open the `secondaryToolbar`.
 - Try to change document rotation at least *twice*.

**Expected behaviour:**
 The document rotation can be changed an arbitrary number of times.

**Actual results:**
 The `secondaryToolbar` closes after changing rotation just once.
This commit is contained in:
Jonas Jenwald 2025-03-11 11:16:56 +01:00
parent 391e84c34b
commit 221eba29b9
2 changed files with 70 additions and 5 deletions

View file

@ -2683,18 +2683,19 @@ function onWheel(evt) {
}
}
function closeSecondaryToolbar(evt) {
function closeSecondaryToolbar({ target }) {
if (!this.secondaryToolbar?.isOpen) {
return;
}
const appConfig = this.appConfig;
const { toolbar, secondaryToolbar } = this.appConfig;
if (
this.pdfViewer.containsElement(evt.target) ||
(appConfig.toolbar?.container.contains(evt.target) &&
this.pdfViewer.containsElement(target) ||
(toolbar?.container.contains(target) &&
!secondaryToolbar?.toolbar.contains(target) &&
// TODO: change the `contains` for an equality check when the bug:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1921984
// is fixed.
!appConfig.secondaryToolbar?.toggleButton.contains(evt.target))
!secondaryToolbar?.toggleButton.contains(target))
) {
this.secondaryToolbar.close();
}