Fixed a problem with how focus was being set.

master
Pacman Ghost 4 years ago
parent f467b2786b
commit 8fac33cb8b
  1. 4
      web/src/App.js

@ -200,16 +200,20 @@ export class App extends React.Component
componentDidUpdate() { componentDidUpdate() {
// we've finished rendering the page, check if we should set focus // we've finished rendering the page, check if we should set focus
if ( this._setFocusTo ) { if ( this._setFocusTo ) {
// yup - set focus to the requested control
if ( this._setFocusTo.current ) if ( this._setFocusTo.current )
this._setFocusTo.current.focus() ; this._setFocusTo.current.focus() ;
else else
this._setFocusTo.focus() ; this._setFocusTo.focus() ;
} }
else { else {
// nope - set focus to the search results (so that Page Up/Down et.al. will work)
if ( ! this._modalFormRef.current ) {
let elem = document.getElementById( "search-results" ) ; let elem = document.getElementById( "search-results" ) ;
if ( elem ) if ( elem )
setTimeout( () => elem.focus(), 10 ) ; setTimeout( () => elem.focus(), 10 ) ;
} }
}
this._setFocusTo = null ; this._setFocusTo = null ;
} }

Loading…
Cancel
Save