In the Distribute Screen, and while working on https://github.com/phetsims/mean-share-and-balance/issues/137, the groupSortInteraction was not able to assign a new selectedGroupItem when the sorting range changed due to our new arrays approach for handling snacks.
The default rangeListener required knowledge of the snack's current value which we no longer have since it is sent to the unusedSnacks array when a plate is removed. A reasonable solution would be to return a null value for getGroupItemValue and then have the rangeListener recalculate. However, the default rangeListener uses null to determine wether groupItem is in an active scene or not. Since this simulation does not have scenes, this logic is not necessary for us.
I decided to create an option in GroupSortInteractionView that can override the default rangeListener to provide it's own logic on when to recalculate. The commits are incoming.
In the Distribute Screen, and while working on https://github.com/phetsims/mean-share-and-balance/issues/137, the groupSortInteraction was not able to assign a new selectedGroupItem when the sorting range changed due to our new arrays approach for handling snacks.
The default rangeListener required knowledge of the snack's current value which we no longer have since it is sent to the unusedSnacks array when a plate is removed. A reasonable solution would be to return a null value for
getGroupItemValue
and then have the rangeListener recalculate. However, the default rangeListener uses null to determine wether groupItem is in an active scene or not. Since this simulation does not have scenes, this logic is not necessary for us.I decided to create an option in GroupSortInteractionView that can override the default rangeListener to provide it's own logic on when to recalculate. The commits are incoming.