From d1586bbbe71cd2f72a7ae8c6afea1f7457664602 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 3 Feb 2021 15:48:40 +0100 Subject: [PATCH] Don't focus the `PasswordPrompt` input-field on load, when the viewer is embedded in e.g. an `iframe` (issue 12951) Given that we don't focus the viewer *itself* (among other things) when the viewer is embedded, I suppose that it makes some sense to not focus the `PasswordPrompt` input-field either on load. In order to improve the overall UX here, if an *incorrect* password was provided we'll still focus the input-field. Fixes 12951 (assuming we care to do so, of course). --- web/app.js | 3 ++- web/password_prompt.js | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/web/app.js b/web/app.js index 9987f9bfe..436e61fd0 100644 --- a/web/app.js +++ b/web/app.js @@ -558,7 +558,8 @@ const PDFViewerApplication = { this.passwordPrompt = new PasswordPrompt( appConfig.passwordOverlay, this.overlayManager, - this.l10n + this.l10n, + this.isViewerEmbedded ); this.pdfOutlineViewer = new PDFOutlineViewer({ diff --git a/web/password_prompt.js b/web/password_prompt.js index 622f620d7..8fa6dd22e 100644 --- a/web/password_prompt.js +++ b/web/password_prompt.js @@ -34,8 +34,15 @@ class PasswordPrompt { * @param {PasswordPromptOptions} options * @param {OverlayManager} overlayManager - Manager for the viewer overlays. * @param {IL10n} l10n - Localization service. + * @param {boolean} [isViewerEmbedded] - If the viewer is embedded, in e.g. + * an