@@ -247,35 +247,25 @@ export const SelectPickerGroupHeading = <OptionValue,>({
247
247
acc [ selectProps . getOptionValue ( option ) ] = true
248
248
return acc
249
249
} , { } )
250
+ const selectedOptionsWithoutGroupOptions = selectedOptions . filter (
251
+ ( selectedOption ) => ! groupOptionsMapByValue [ selectProps . getOptionValue ( selectedOption ) ] ,
252
+ )
250
253
251
254
// Clear all the selection(s) in the group if any of the option is selected
252
255
if ( checkboxValue ) {
253
- selectProps ?. onChange ?.(
254
- selectedOptions . filter (
255
- ( selectedOption ) => ! groupOptionsMapByValue [ selectProps . getOptionValue ( selectedOption ) ] ,
256
- ) ,
257
- {
258
- action : ReactSelectInputAction . deselectOption ,
259
- option : null ,
260
- } ,
261
- )
256
+ selectProps ?. onChange ?.( selectedOptionsWithoutGroupOptions , {
257
+ action : ReactSelectInputAction . deselectOption ,
258
+ option : null ,
259
+ } )
262
260
263
261
return
264
262
}
265
263
266
264
// Select all options
267
- selectProps ?. onChange ?.(
268
- [
269
- ...selectedOptions . filter (
270
- ( selectedOption ) => ! groupOptionsMapByValue [ selectProps . getOptionValue ( selectedOption ) ] ,
271
- ) ,
272
- ...structuredClone ( groupHeadingOptions ) ,
273
- ] ,
274
- {
275
- action : ReactSelectInputAction . selectOption ,
276
- option : null ,
277
- } ,
278
- )
265
+ selectProps ?. onChange ?.( [ ...selectedOptionsWithoutGroupOptions , ...structuredClone ( groupHeadingOptions ) ] , {
266
+ action : ReactSelectInputAction . selectOption ,
267
+ option : null ,
268
+ } )
279
269
}
280
270
281
271
const handleToggleCheckbox = ( e : ChangeEvent < HTMLInputElement > ) => {
0 commit comments