@@ -193,6 +193,19 @@ const ComboBox: FC<ComboBoxProps> = ({
193
193
[ areaProvider . shouldChangeColor ] ,
194
194
) ;
195
195
196
+ const shouldDisableActions = useMemo ( ( ) => {
197
+ if ( ! selectedItem ) {
198
+ return false ;
199
+ }
200
+
201
+ const combinedLists = lists . flatMap ( ( list ) => list . list ) ;
202
+
203
+ return (
204
+ combinedLists . length === 1 &&
205
+ combinedLists . some ( ( item ) => item . value === selectedItem . value )
206
+ ) ;
207
+ } , [ lists , selectedItem ] ) ;
208
+
196
209
useEffect ( ( ) => {
197
210
if ( styledComboBoxElementRef . current && ! container ) {
198
211
const el = styledComboBoxElementRef . current as HTMLElement ;
@@ -240,6 +253,10 @@ const ComboBox: FC<ComboBoxProps> = ({
240
253
) ;
241
254
242
255
const handleOpen = useCallback ( ( ) => {
256
+ if ( shouldDisableActions ) {
257
+ return ;
258
+ }
259
+
243
260
if ( styledComboBoxElementRef . current && newContainer ) {
244
261
const {
245
262
left : comboBoxLeft ,
@@ -265,7 +282,7 @@ const ComboBox: FC<ComboBoxProps> = ({
265
282
266
283
setIsAnimating ( true ) ;
267
284
}
268
- } , [ newContainer , direction ] ) ;
285
+ } , [ shouldDisableActions , newContainer , direction ] ) ;
269
286
270
287
const handleClose = useCallback ( ( ) => {
271
288
setIsAnimating ( false ) ;
@@ -720,13 +737,15 @@ const ComboBox: FC<ComboBoxProps> = ({
720
737
< Icon icons = { [ 'fa fa-times' ] } />
721
738
</ StyledComboBoxClearIconWrapper >
722
739
) }
723
- < StyledComboBoxIconWrapper
724
- $shouldShowBorderLeft = {
725
- shouldShowClearIcon === true && internalSelectedItem !== undefined
726
- }
727
- >
728
- < Icon icons = { [ 'fa fa-chevron-down' ] } />
729
- </ StyledComboBoxIconWrapper >
740
+ { ! shouldDisableActions && (
741
+ < StyledComboBoxIconWrapper
742
+ $shouldShowBorderLeft = {
743
+ shouldShowClearIcon === true && internalSelectedItem !== undefined
744
+ }
745
+ >
746
+ < Icon icons = { [ 'fa fa-chevron-down' ] } />
747
+ </ StyledComboBoxIconWrapper >
748
+ ) }
730
749
</ StyledComboBoxHeader >
731
750
{ portal }
732
751
</ StyledComboBox >
@@ -755,6 +774,7 @@ const ComboBox: FC<ComboBoxProps> = ({
755
774
placeholderText ,
756
775
shouldShowClearIcon ,
757
776
handleClear ,
777
+ shouldDisableActions ,
758
778
portal ,
759
779
] ,
760
780
) ;
0 commit comments