1- import React , { useRef , useState } from 'react' ;
1+ import React , { useRef } from 'react' ;
22import classNames from 'classnames' ;
33import { useTranslation } from 'react-i18next' ;
44import { useDispatch , useSelector } from 'react-redux' ;
@@ -33,21 +33,10 @@ export default function SideBar() {
3333
3434 const sidebarOptionsRef = useRef ( null ) ;
3535
36- const [ isFocused , setIsFocused ] = useState ( false ) ;
37-
3836 const isAuthenticated = useSelector ( getAuthenticated ) ;
3937
4038 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 ) ;
5140 } ;
5241
5342 const toggleProjectOptions = ( e ) => {
@@ -96,7 +85,6 @@ export default function SideBar() {
9685 ref = { sidebarOptionsRef }
9786 onClick = { toggleProjectOptions }
9887 onBlur = { onBlurComponent }
99- onFocus = { onFocusComponent }
10088 >
10189 < PlusIcon focusable = "false" aria-hidden = "true" />
10290 </ button >
@@ -109,7 +97,6 @@ export default function SideBar() {
10997 setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
11098 } }
11199 onBlur = { onBlurComponent }
112- onFocus = { onFocusComponent }
113100 >
114101 { t ( 'Sidebar.AddFolder' ) }
115102 </ button >
@@ -122,7 +109,6 @@ export default function SideBar() {
122109 setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
123110 } }
124111 onBlur = { onBlurComponent }
125- onFocus = { onFocusComponent }
126112 >
127113 { t ( 'Sidebar.AddFile' ) }
128114 </ button >
@@ -136,7 +122,6 @@ export default function SideBar() {
136122 setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
137123 } }
138124 onBlur = { onBlurComponent }
139- onFocus = { onFocusComponent }
140125 >
141126 { t ( 'Sidebar.UploadFile' ) }
142127 </ button >
0 commit comments