@@ -46,6 +46,7 @@ export type TSelectableGroupProps = {
4646 selectionModeClass ?: string
4747 // Event that will fire when items are selected. Passes an array of keys.
4848 onSelectionFinish ?: Function
49+ onUnselectedFinish ?: ( items : TSelectableItem [ ] ) => void
4950 onSelectionClear ?: Function
5051 onSelectedItemUnmount ?: Function
5152 enableDeselect ?: boolean
@@ -168,6 +169,15 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
168169 scrollLeft : 0 ,
169170 }
170171
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+
171181 componentDidMount ( ) {
172182 if ( this . props . scrollContainer ) {
173183 this . scrollContainer = document . querySelector ( this . props . scrollContainer )
@@ -459,6 +469,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
459469
460470 this . setState ( { selectionMode : false } )
461471 this . props . onSelectionFinish ! ( [ ...this . selectedItems ] )
472+ this . onUnselectedFinish ( )
462473 this . props . onSelectionClear ! ( )
463474 }
464475
@@ -474,6 +485,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
474485
475486 this . setState ( { selectionMode : true } )
476487 this . props . onSelectionFinish ! ( [ ...this . selectedItems ] )
488+ this . onUnselectedFinish ( )
477489 }
478490
479491 isInIgnoreList ( target : HTMLElement | null ) {
@@ -619,6 +631,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
619631 height : 0 ,
620632 } )
621633 this . props . onSelectionFinish ! ( [ ...this . selectedItems ] )
634+ this . onUnselectedFinish ( )
622635 }
623636
624637 this . toggleSelectionMode ( )
@@ -695,6 +708,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
695708 )
696709
697710 onSelectionFinish ! ( [ ...this . selectedItems ] , this . clickedItem )
711+ this . onUnselectedFinish ( )
698712
699713 if ( evt . which === 1 ) {
700714 this . preventEvent ( evt . target , 'click' )
0 commit comments