diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-04-07 19:07:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-07 19:07:42 -0400 |
commit | e444141511b6d06c4bfe370febc5e3c5bff30e3d (patch) | |
tree | 3845af5f232e9d7b5fe2338c6e0c573a3a339235 /ext/js/dom/document-focus-controller.js | |
parent | e14b52ef84be7feeab60167605fd10918a242cd3 (diff) |
Fix autofocus sometimes not working on the search page (#1597)
Diffstat (limited to 'ext/js/dom/document-focus-controller.js')
-rw-r--r-- | ext/js/dom/document-focus-controller.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/js/dom/document-focus-controller.js b/ext/js/dom/document-focus-controller.js index 649b5abe..b2d40db8 100644 --- a/ext/js/dom/document-focus-controller.js +++ b/ext/js/dom/document-focus-controller.js @@ -22,13 +22,17 @@ * focus a dummy element inside the main content, which gives keyboard scroll focus to that element. */ class DocumentFocusController { - constructor() { + constructor(autofocusElementSelector=null) { + this._autofocusElement = (autofocusElementSelector !== null ? document.querySelector(autofocusElementSelector) : null); this._contentScrollFocusElement = document.querySelector('#content-scroll-focus'); } prepare() { window.addEventListener('focus', this._onWindowFocus.bind(this), false); this._updateFocusedElement(false); + if (this._autofocusElement !== null && document.activeElement !== this._autofocusElement) { + this._autofocusElement.focus({preventScroll: true}); + } } blurElement(element) { |