1
- import React , { useRef , useState } from 'react' ;
1
+ import React , { useRef } from 'react' ;
2
2
import classNames from 'classnames' ;
3
3
import { useTranslation } from 'react-i18next' ;
4
4
import { useDispatch , useSelector } from 'react-redux' ;
@@ -33,21 +33,10 @@ export default function SideBar() {
33
33
34
34
const sidebarOptionsRef = useRef ( null ) ;
35
35
36
- const [ isFocused , setIsFocused ] = useState ( false ) ;
37
-
38
36
const isAuthenticated = useSelector ( getAuthenticated ) ;
39
37
40
38
const onBlurComponent = ( ) => {
41
- setIsFocused ( false ) ;
42
- setTimeout ( ( ) => {
43
- if ( ! isFocused ) {
44
- dispatch ( closeProjectOptions ( ) ) ;
45
- }
46
- } , 200 ) ;
47
- } ;
48
-
49
- const onFocusComponent = ( ) => {
50
- setIsFocused ( true ) ;
39
+ setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 200 ) ;
51
40
} ;
52
41
53
42
const toggleProjectOptions = ( e ) => {
@@ -96,7 +85,6 @@ export default function SideBar() {
96
85
ref = { sidebarOptionsRef }
97
86
onClick = { toggleProjectOptions }
98
87
onBlur = { onBlurComponent }
99
- onFocus = { onFocusComponent }
100
88
>
101
89
< PlusIcon focusable = "false" aria-hidden = "true" />
102
90
</ button >
@@ -109,7 +97,6 @@ export default function SideBar() {
109
97
setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
110
98
} }
111
99
onBlur = { onBlurComponent }
112
- onFocus = { onFocusComponent }
113
100
>
114
101
{ t ( 'Sidebar.AddFolder' ) }
115
102
</ button >
@@ -122,7 +109,6 @@ export default function SideBar() {
122
109
setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
123
110
} }
124
111
onBlur = { onBlurComponent }
125
- onFocus = { onFocusComponent }
126
112
>
127
113
{ t ( 'Sidebar.AddFile' ) }
128
114
</ button >
@@ -136,7 +122,6 @@ export default function SideBar() {
136
122
setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
137
123
} }
138
124
onBlur = { onBlurComponent }
139
- onFocus = { onFocusComponent }
140
125
>
141
126
{ t ( 'Sidebar.UploadFile' ) }
142
127
</ button >
0 commit comments