14
14
* limitations under the License.
15
15
*/
16
16
17
- import { useEffect , useMemo , useState } from 'react'
17
+ import { useEffect , useMemo , useRef , useState } from 'react'
18
18
import { ReactComponent as ICFilter } from '@Icons/ic-filter.svg'
19
19
import { ReactComponent as ICFilterApplied } from '@Icons/ic-filter-applied.svg'
20
20
import { ComponentSizeType } from '@Shared/constants'
@@ -33,6 +33,8 @@ const FilterSelectPicker = ({
33
33
options,
34
34
...props
35
35
} : FilterSelectPickerProps ) => {
36
+ const selectRef = useRef < SelectPickerProps < string | number , true > [ 'selectRef' ] [ 'current' ] > ( )
37
+
36
38
const [ isMenuOpen , setIsMenuOpen ] = useState ( false )
37
39
const { triggerAutoClickTimestamp, setTriggerAutoClickTimestampToNow, resetTriggerAutoClickTimestamp } =
38
40
useTriggerAutoClickTimestamp ( )
@@ -81,6 +83,12 @@ const FilterSelectPicker = ({
81
83
// Added !e to ensure it works for both click and keyboard shortcut event
82
84
if ( ! e || e . isTrusted ) {
83
85
closeMenu ( )
86
+ } else {
87
+ // If the event is not triggered by the user, focus on the select picker
88
+ // As it loses focus when auto-click is triggered and menu is not closed
89
+ setTimeout ( ( ) => {
90
+ selectRef . current . focus ( )
91
+ } , 100 )
84
92
}
85
93
}
86
94
@@ -116,8 +124,9 @@ const FilterSelectPicker = ({
116
124
117
125
return (
118
126
< div className = "dc__mxw-250" >
119
- < SelectPicker
127
+ < SelectPicker < string | number , true >
120
128
{ ...props }
129
+ selectRef = { selectRef }
121
130
options = { options }
122
131
value = { selectedOptions }
123
132
isMulti
0 commit comments