@@ -46,6 +46,7 @@ export type TSelectableGroupProps = {
46
46
selectionModeClass ?: string
47
47
// Event that will fire when items are selected. Passes an array of keys.
48
48
onSelectionFinish ?: Function
49
+ onUnselectedFinish ?: ( items : TSelectableItem [ ] ) => void
49
50
onSelectionClear ?: Function
50
51
onSelectedItemUnmount ?: Function
51
52
enableDeselect ?: boolean
@@ -168,6 +169,15 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
168
169
scrollLeft : 0 ,
169
170
}
170
171
172
+ onUnselectedFinish ( ) {
173
+ if ( ! this . props . onUnselectedFinish ) return
174
+ const a = this . registry
175
+ const b = this . selectedItems
176
+ const unselected = new Set (
177
+ [ ...a ] . filter ( x => ! b . has ( x ) ) ) ;
178
+ this . props . onUnselectedFinish ( [ ...unselected ] )
179
+ }
180
+
171
181
componentDidMount ( ) {
172
182
if ( this . props . scrollContainer ) {
173
183
this . scrollContainer = document . querySelector ( this . props . scrollContainer )
@@ -459,6 +469,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
459
469
460
470
this . setState ( { selectionMode : false } )
461
471
this . props . onSelectionFinish ! ( [ ...this . selectedItems ] )
472
+ this . onUnselectedFinish ( )
462
473
this . props . onSelectionClear ! ( )
463
474
}
464
475
@@ -474,6 +485,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
474
485
475
486
this . setState ( { selectionMode : true } )
476
487
this . props . onSelectionFinish ! ( [ ...this . selectedItems ] )
488
+ this . onUnselectedFinish ( )
477
489
}
478
490
479
491
isInIgnoreList ( target : HTMLElement | null ) {
@@ -619,6 +631,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
619
631
height : 0 ,
620
632
} )
621
633
this . props . onSelectionFinish ! ( [ ...this . selectedItems ] )
634
+ this . onUnselectedFinish ( )
622
635
}
623
636
624
637
this . toggleSelectionMode ( )
@@ -695,6 +708,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
695
708
)
696
709
697
710
onSelectionFinish ! ( [ ...this . selectedItems ] , this . clickedItem )
711
+ this . onUnselectedFinish ( )
698
712
699
713
if ( evt . which === 1 ) {
700
714
this . preventEvent ( evt . target , 'click' )
0 commit comments