Closed Nancy-Salpepi closed 2 months ago
This behavior doesn't always happen on the Balance Point screen and I can't quite figure out what I may be doing differently.
I'm going to take a stab at this. @jessegreenberg I'll let you know if I'll need your help.
I think this is now being caught by an assertion that was turned on after some work I did yesterday in https://github.com/phetsims/soccer-common/issues/7. Great news, because we have a clear starting point to search from.
@jessegreenberg and I worked on some behavior questions for groupSortInteraction today that ended up solving this issue. However I did notice some inconsistencies in where the sim was focusing after a mouse even.
JG and I committed code that would reset keyboard state and fire a blur event whenever we received a mouse down
event. Our understanding is that upon the user hitting tab
the next item in the pdom would be focused (in the case of group sort, the first number spinner). However, I noticed that sometimes tab would lead me to the number spinner, and sometimes it would focus on the group again.
@jessegreenberg would love your thoughts on how buggy this feels to you? It seems strange but I'm not sure how broken it feels.
https://github.com/user-attachments/assets/14a3a257-b888-4e04-8ba3-b718e61441f4
I took a brief look. To consistently reproduce:
I confirmed that in both cases, we successfully call blur
from https://github.com/phetsims/scenery-phet/commit/5fa5a3130c9cd81f2323cf22ff0f8ef2b6469d97. Because of that, this should not be an issue and the behavior should be correct.
This may be happening because of a DOM state change triggered by GroupSortInteractionView, if something causes the PDOM elements to re-render (like changing the accessibleName
) the browser might behave differently after the blur
. Or it may be happening because of https://github.com/phetsims/joist/issues/750#issuecomment-2261048786. I didn't investigate further and recommend continuing without fixing.
Back to you @marlitas.
Thanks @jessegreenberg. This is ready to cherry pick!
The original issue is fixed so I am going to close this one. A new issue related to this can be found at https://github.com/phetsims/mean-share-and-balance/issues/343
Sorry but I need to reopen. Here is one way to get it to happen reliably:
https://github.com/user-attachments/assets/c3be25f0-9588-47b6-84ac-5bfc48b53f70
@jbphet and I were surprised to find that a keyboard event was not cancelling a pointer. We noticed that you can do also move the same element with both keyboard and mouse at the same time as shown in the published version of Faraday's Electromagnetic Lab. We are curious if this is expected behavior that individual sims need to handle.
https://github.com/user-attachments/assets/6daf4e37-7dfa-42b7-9ba9-c38338b81b1f
Discussed with @marlitas. Indeed, this is a problem for several sims but we have generally been deferring issues related to using mouse and keyboard simultaneously. @marlitas described that this can create serious problems for GrabDragInteraction and this sim, so it would be ideal if it can be fixed.
I will take a look at GroupSortInteractionView to see if there is a way we can interrupt the pointer-related drag listeners when keys are pressed. I will also run the problem by @jonathanolson to see if he has any thoughts about fixing this more deeply in scenery (I was nervous about generally interrupting listeners whenever a key or tab is pressed, that could prevent mouse+keyboard behavior we might want in the future).
@marlitas will also check with design leads about whether this needs to be fixed before publishing.
We will check in again on Monday.
OK, I have a couple of ideas. I noticed that in the unbuilt version, an assertion is thrown before the bug in https://github.com/phetsims/mean-share-and-balance/issues/329#issuecomment-2289600534 which is helpful.
@marlitas @jbphet can you please review?
1) You may be able to put model.resetInteractionState();
at the top of the focus
listener in GroupSortInteractionView. That makes the assertion failure go away. This is a simple change. But I don't know enough about GroupSortInteraction to say whether it is working correctly.
2) We can give GroupSortInteractionModel emitters to reset keyboard and mouse listener when necessary. GroupSortInteractionView can handle the interruption for keyboard input. But it will be up to clients to implement interruption for mouse/touch. This is a similar idea to setMouseSortedGroupItem
. Here is a patch with this. Tested lightly but will need some further review and cleanup for disposal and such.
@jessegreenberg thank you for the investigation and work here. I think it will be valuable to determine wether this is something GroupSortInteraction should handle in general and I added it as a discussion point for dev meeting. The team has decided that this is not blocking for MSaB and we will proceed by ignoring any dual mouse and keyboard bugs with QA looking out for the following:
QA, if any of the above occur please flag that as it is much more critical and may need to be addressed.
Thanks!
I'm not seeing any of the scenarios in https://github.com/phetsims/mean-share-and-balance/issues/329#issuecomment-2297731877. Closing.
Test device MacBook Air M1 chip
Operating System 14.5
Browser Safari 17.5
Problem description For https://github.com/phetsims/qa/issues/1121, on the Distribute and Balance Point screens, the focus highlights for keyboard nav will fail to appear after moving a chocolate bar or a soccer ball with alt input, then moving the same/different bar/ball with the mouse and then switching back to keyboard navigation.
Steps to reproduce
HOME
,END
orarrow
keys-- they will move the original bar.Visuals
https://github.com/user-attachments/assets/ab8beade-e8cd-4942-8b85-fdcadd727e63