Browse Source

fixed focus repeating every 500ms

keplyx 4 years ago
parent
commit
4cb0d2f8b5
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      components/CustomHeader.js

+ 2
- 2
components/CustomHeader.js View File

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

Loading…
Cancel
Save