Merge pull request #8609 from Snuffleupagus/findbar-more-adjustWidth

Ensure that `PDFFindBar._adjustWidth` is called in all situations where the width of the findbar might have changed
This commit is contained in:
Tim van der Meij 2017-07-14 13:34:17 +02:00 committed by GitHub
commit d7367f102e

View File

@ -140,10 +140,10 @@ class PDFFindBar {
this.findField.setAttribute('data-status', status); this.findField.setAttribute('data-status', status);
Promise.resolve(findMsg).then((msg) => { Promise.resolve(findMsg).then((msg) => {
this.findMsg.textContent = msg; this.findMsg.textContent = msg;
this._adjustWidth();
}); });
this.updateResultsCount(matchCount); this.updateResultsCount(matchCount);
this._adjustWidth();
} }
updateResultsCount(matchCount) { updateResultsCount(matchCount) {
@ -151,15 +151,18 @@ class PDFFindBar {
return; // No UI control is provided. return; // No UI control is provided.
} }
// If there are no matches, hide the counter.
if (!matchCount) { if (!matchCount) {
// If there are no matches, hide and reset the counter.
this.findResultsCount.classList.add('hidden'); this.findResultsCount.classList.add('hidden');
return; this.findResultsCount.textContent = '';
} else {
// Update and show the match counter.
this.findResultsCount.textContent = matchCount.toLocaleString();
this.findResultsCount.classList.remove('hidden');
} }
// Since `updateResultsCount` may be called from `PDFFindController`,
// Create and show the match counter. // ensure that the width of the findbar is always updated correctly.
this.findResultsCount.textContent = matchCount.toLocaleString(); this._adjustWidth();
this.findResultsCount.classList.remove('hidden');
} }
open() { open() {