Skip to content

Commit

Permalink
Fix mass interrupting and focus handling on reset, see #399 and #418
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Oct 1, 2024
1 parent 9415778 commit a11b97c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions js/common/model/Mass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ export default abstract class Mass extends PhetioObject {
*/
public reset( resetInternalVisibleProperty = true ): void {

this.interruptedEmitter.emit();

// Clear velocity and force on the p2 body
this.body.velocity[ 0 ] = 0;
this.body.velocity[ 1 ] = 0;
Expand Down
6 changes: 5 additions & 1 deletion js/common/view/MassView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,12 @@ export default abstract class MassView extends Disposable {
} );
}
const resetListener = () => {

// After reset, do not assume the cursor is over an object. It will be updated the next time the cursor moves.
this.isCursorOverProperty.reset();
this.isKeyboardFocusedProperty.reset();

// NOTE: Do not reset the focus state (isKeyboardFocusedProperty) because it may persist through a reset (like
// with global keyboard shortcuts) https://github.com/phetsims/density-buoyancy-common/issues/399

this.grabDragInteraction && this.grabDragInteraction.reset();
};
Expand Down

0 comments on commit a11b97c

Please sign in to comment.