summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-25 22:19:44 -0500
committerGitHub <noreply@github.com>2021-01-25 22:19:44 -0500
commit43c9a5eb6a19d4056749718e11f16296be2d52c2 (patch)
treed136bd9e633611538db795e9614abed01d8098a2 /ext
parent34fed22ccb34720a16097baebc25fe96278be93c (diff)
Fix search box resizing (#1316)
* Don't resize the search box unless it's necessary * Allow search box to shrink under certain circumstances
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/search.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 3b7e8299..b445c161 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -149,13 +149,15 @@ class DisplaySearch extends Display {
if (typeof source !== 'string') { source = ''; }
- this._queryInput.value = source;
- this._updateSearchHeight();
+ if (this._queryInput.value !== source) {
+ this._queryInput.value = source;
+ this._updateSearchHeight(true);
+ }
this._setIntroVisible(!valid, animate);
}
_onSearchInput() {
- this._updateSearchHeight();
+ this._updateSearchHeight(false);
}
_onSearchKeydown(e) {
@@ -185,6 +187,7 @@ class DisplaySearch extends Display {
text = text.substring(0, maximumClipboardSearchLength);
}
this._queryInput.value = text;
+ this._updateSearchHeight(true);
this._search(animate, false, autoSearchClipboardContent);
}
@@ -357,11 +360,14 @@ class DisplaySearch extends Display {
this.setContent(details);
}
- _updateSearchHeight() {
+ _updateSearchHeight(shrink) {
const node = this._queryInput;
+ if (shrink) {
+ node.style.height = '0';
+ }
const {scrollHeight} = node;
const currentHeight = node.getBoundingClientRect().height;
- if (scrollHeight >= currentHeight - 1) {
+ if (shrink || scrollHeight >= currentHeight - 1) {
node.style.height = `${scrollHeight}px`;
}
}