Skip to content

Commit

Permalink
fix: remove correct listener & add extra event
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Wizard committed Mar 15, 2023
1 parent 61d2fcd commit 56cfdf8
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -141,18 +141,20 @@ export default function useSelectionsInteractions({ selectionState, selections,
}, [onMouseUpDoc]);

useEffect(() => {
const onDeactivated = () => {
const clearItemStates = () => {
selectionState.clearItemStates(false);
};
const onCleared = () => {
selectionState.clearItemStates(true);
selectionState.triggerStateChanged();
};

selections.on('deactivated', onDeactivated);
selections.on('clearItemStates', clearItemStates);
selections.on('deactivated', clearItemStates);
selections.on('cleared', onCleared);
return () => {
selections.removeListener('activated', onDeactivated);
selections.removeListener('clearItemStates', clearItemStates);
selections.removeListener('deactivated', clearItemStates);
selections.removeListener('cleared', onCleared);
};
}, [selections]);
Expand Down

0 comments on commit 56cfdf8

Please sign in to comment.