make non-hotkey keys focus input on search page
The issue was that scanning on search page introduced a way to lose focus of the query input, and the new feature that the search page hotkey focuses an existing search page instead of opening a new one made it more obvious. Now every key that isn't a hotkey focuses the query input, and typing text into the box scrolls it into view in case it wasn't there when searching. There is an accessibility issue that this can cause, because now tab also focuses the query input before it focuses the next element. I didn't implement a workaround for that because it would have been more complicated than this simple fix. Fixes #263
This commit is contained in:
parent
43ddffeb7a
commit
a716a52cab
@ -79,6 +79,7 @@ class DisplaySearch extends Display {
|
|||||||
|
|
||||||
onSearchInput() {
|
onSearchInput() {
|
||||||
this.updateSearchButton();
|
this.updateSearchButton();
|
||||||
|
this.query.scrollIntoView();
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearch(e) {
|
onSearch(e) {
|
||||||
@ -94,6 +95,12 @@ class DisplaySearch extends Display {
|
|||||||
this.onSearchQueryUpdated(query, true);
|
this.onSearchQueryUpdated(query, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onKeyDown(e) {
|
||||||
|
if (!super.onKeyDown(e)) {
|
||||||
|
this.query.focus({preventScroll: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async onSearchQueryUpdated(query, animate) {
|
async onSearchQueryUpdated(query, animate) {
|
||||||
try {
|
try {
|
||||||
const valid = (query.length > 0);
|
const valid = (query.length > 0);
|
||||||
|
@ -157,8 +157,10 @@ class Display {
|
|||||||
const handler = handlers[key];
|
const handler = handlers[key];
|
||||||
if (handler(this, e)) {
|
if (handler(this, e)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onWheel(e) {
|
onWheel(e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user