focus and scroll to input only when it's needed
This commit is contained in:
parent
fe8eb76928
commit
9132814ccf
@ -79,7 +79,11 @@ class DisplaySearch extends Display {
|
|||||||
|
|
||||||
onSearchInput() {
|
onSearchInput() {
|
||||||
this.updateSearchButton();
|
this.updateSearchButton();
|
||||||
this.query.scrollIntoView();
|
|
||||||
|
const queryElementRect = this.query.getBoundingClientRect();
|
||||||
|
if (queryElementRect.top < 0 || queryElementRect.bottom > window.innerHeight) {
|
||||||
|
this.query.scrollIntoView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearch(e) {
|
onSearch(e) {
|
||||||
@ -123,7 +127,7 @@ class DisplaySearch extends Display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!super.onKeyDown(e) && !preventFocus) {
|
if (!super.onKeyDown(e) && !preventFocus && document.activeElement !== this.query) {
|
||||||
this.query.focus({preventScroll: true});
|
this.query.focus({preventScroll: true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user