From 2971f522d43ee7173c4615bafa19f9b680736267 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 10 Jun 2017 13:10:23 +0200 Subject: [PATCH] Prevent the Zoom dropdown from intermittently displaying an incorrect custom scale in Firefox (PR 8394 follow-up) After PR 8394, at least in Firefox, the Zoom dropdown now frequently displays an old custom scale instead of the correct one. To see this behaviour, the following STR works for me: 1. Open https://mozilla.github.io/pdf.js/web/viewer.html. 2. Zoom in, by clicking on the corresponding button in the toolbar. 3. Run `PDFViewerApplication.pdfViewer.currentScaleValue` in the console. 4. Compare what's displayed in the Zoom dropdown with what's printed in the console. (If no difference can be observed, try repeating steps 2 through 4 a couple of times.) I really don't understand why this happens, but it seems that waiting until a custom scale has been set *before* selecting it fixes things in Firefox (and works fine in e.g. Chrome as well). Note that this patch thus makes this particular piece of the code consistent with the state prior to PR 8394. --- web/toolbar.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web/toolbar.js b/web/toolbar.js index e44ecc7b0..3e486edcf 100644 --- a/web/toolbar.js +++ b/web/toolbar.js @@ -194,11 +194,10 @@ var Toolbar = (function ToolbarClosure() { if (!predefinedValueFound) { var customScale = Math.round(scale * 10000) / 100; this.l10n.get('page_scale_percent', { scale: customScale, }, - '{{scale}}%'). - then((msg) => { + '{{scale}}%').then((msg) => { items.customScaleOption.textContent = msg; + items.customScaleOption.selected = true; }); - items.customScaleOption.selected = true; } };