Merge pull request #12952 from Snuffleupagus/issue-12951

Don't focus the `PasswordPrompt` input-field on load, when the viewer is embedded in e.g. an `iframe` (issue 12951)
This commit is contained in:
Tim van der Meij 2021-02-03 20:52:38 +01:00 committed by GitHub
commit 27ffbdf7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -558,7 +558,8 @@ const PDFViewerApplication = {
this.passwordPrompt = new PasswordPrompt(
appConfig.passwordOverlay,
this.overlayManager,
this.l10n
this.l10n,
this.isViewerEmbedded
);
this.pdfOutlineViewer = new PDFOutlineViewer({

View File

@ -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 <iframe> or an <object>. The default value is `false`.
*/
constructor(options, overlayManager, l10n = NullL10n) {
constructor(
options,
overlayManager,
l10n = NullL10n,
isViewerEmbedded = false
) {
this.overlayName = options.overlayName;
this.container = options.container;
this.label = options.label;
@ -44,6 +51,7 @@ class PasswordPrompt {
this.cancelButton = options.cancelButton;
this.overlayManager = overlayManager;
this.l10n = l10n;
this._isViewerEmbedded = isViewerEmbedded;
this.updateCallback = null;
this.reason = null;
@ -67,7 +75,12 @@ class PasswordPrompt {
open() {
this.overlayManager.open(this.overlayName).then(() => {
this.input.focus();
if (
!this._isViewerEmbedded ||
this.reason === PasswordResponses.INCORRECT_PASSWORD
) {
this.input.focus();
}
let promptString;
if (this.reason === PasswordResponses.INCORRECT_PASSWORD) {