Skip to content

Commit

Permalink
Add callback for mouse down event to reset keyboard interaction state…
Browse files Browse the repository at this point in the history
…, see: phetsims/mean-share-and-balance#329

(cherry picked from commit 5fa5a31)
  • Loading branch information
marlitas committed Aug 14, 2024
1 parent 9790871 commit 715947b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,12 @@ export default class GroupSortInteractionModel<ItemModel> extends EnabledCompone
* switching between scenes.
*/
public resetInteractionState(): void {
this.selectedGroupItemProperty.reset();

// isGroupItemKeyboardGrabbedProperty needs to be reset before the selectedGroupItemProperty, because a
// selectedGroupItemProperty listener is relying on an accurate isGroupItemKeyboardGrabbedProperty.value
// to fire an assertion.
this.isGroupItemKeyboardGrabbedProperty.reset();
this.selectedGroupItemProperty.reset();
this.isKeyboardFocusedProperty.reset();
}

Expand Down
10 changes: 10 additions & 0 deletions js/accessibility/group-sort/view/GroupSortInteractionView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ export default class GroupSortInteractionView<ItemModel, ItemNode extends Node>
// When you mouse over while focused, the highlights are hidden, and so update the state (even though we are
// still technically keyboard focused). This will assist in showing the mouse cue, https://github.com/phetsims/center-and-variability/issues/406
isKeyboardFocusedProperty.value = false;
},
down: () => {

// When the group is clicked, reset the interaction state to stop keyboard input logic. We only support
// one mode of input at a time.
model.resetInteractionState();

// We want to remove focus from this node entirely to prevent the focus highlight from showing up when
// there is no selected group item.
primaryFocusedNode.blur();
}
};

Expand Down

0 comments on commit 715947b

Please sign in to comment.