Skip to content

Commit cb0e8d3

Browse files
authored
Merge pull request #3205 from suprabhat15/fix-projectoptions-closing
fix closing of projectoptions on losing focus
2 parents 44d967d + 28b9663 commit cb0e8d3

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

client/modules/IDE/components/Sidebar.jsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useState } from 'react';
1+
import React, { useRef } from 'react';
22
import classNames from 'classnames';
33
import { useTranslation } from 'react-i18next';
44
import { 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

Comments
 (0)