phetsims / density-buoyancy-common

Common code for the Density and Buoyancy simulations
GNU General Public License v3.0
0 stars 2 forks source link

Panning with keyboard navigation breaks when switching screens while a moveable object has focus #210

Closed Nancy-Salpepi closed 1 month ago

Nancy-Salpepi commented 3 months ago

Test device MacBook Air M1 chip

Operating System 14.5

Browser Safari and Chrome

Problem description For https://github.com/phetsims/qa/issues/1095, on all sims and all screens, if I change screens using the mouse while a moveable object, such as a block or scale, has keyboard focus, when I return to that screen I am unable to pan with keyboard navigation. This may be a moot point now since we are switching to grab drag interaction, but still thought I should report this.

Seems specific to these sims. I also tested FEL on main and didn't see this problem when moving the magnet.

Steps to reproduce Here is an example:

  1. In Buoyancy: on the Compare screen tab to block 1A
  2. While the block has keyboard focus, click on the Explore screen icon with your mouse
  3. Click on the Compare screen icon with your mouse
  4. Tab to the block again and zoom in
  5. Move the block offscreen

Visuals

https://github.com/phetsims/density-buoyancy-common/assets/87318828/29616a39-34a0-4434-8c1f-8f41ec582547

samreid commented 3 months ago

This may be a moot point now since we are switching to grab drag interaction,

Good point, let's put this on hold until after #209

samreid commented 1 month ago

Same problem now that we have GrabDragInteraction. Not sure how to solve it. @jessegreenberg or @zepumph any recommendations how to investigate?

jessegreenberg commented 1 month ago

One thing I noticed is that the focused Node has infinite Bounds. The AnimatedPanZoomListener won't be able to pan to keep that target in view.

image

Every once in a while, I noticed the bounds become finite and the problem went away. I would see the focus highlight jostle a little bit and wrap tightly around the mass graphic. Then it would shift away. This might be related to https://github.com/phetsims/density-buoyancy-common/issues/209#issuecomment-2286597605 and #327

If the infinite bounds cannot be fixed, let me know and we can explore workarounds in scenery.

zepumph commented 1 month ago

Thanks for the lead @jessegreenberg. That was really helpful. This was the chunk of code that was breaking things:

https://github.com/phetsims/density-buoyancy-common/commit/df2334f32ae19c5ab4c557de8dda661ed1084805#diff-ef1ad0c1582c6f2a99055c4065e1a884457a370ee52ec8d8017cc7d79e679cdcL192-L195

This is fixed now. Closing.