fixed focus repeating every 500ms

This commit is contained in:
keplyx 2019-11-15 19:38:43 +01:00
parent ab7e8f92fc
commit 4cb0d2f8b5

View file

@ -43,9 +43,9 @@ export default class CustomHeader extends React.Component<Props> {
};
componentDidMount() {
if (this.refs.searchInput !== undefined && this.props.shouldFocusSearchBar) {
if (this.refs.searchInput !== undefined && this.refs.searchInput._root !== undefined && this.props.shouldFocusSearchBar) {
// does not work if called to early for some reason...
setInterval(() => this.refs.searchInput._root.focus(), 500);
setTimeout(() => this.refs.searchInput._root.focus(), 500);
}
}