-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Focus is not handled properly for dialogs. #194
Comments
In addition to not setting focus on the close button, we're also not restoring focus to the push button when the dialog is closed. @jessegreenberg please provide guidance here. Is there something that needs to be done to set focus when a Dialog is opened? Why doesn't Dialog handle that automatically? |
Here's the relevant code related to keyboardHelpDialogCapsule = new PhetioCapsule( tandem => {
const keyboardHelpDialog = new KeyboardHelpDialog( content, {
tandem: tandem
} );
keyboardHelpDialog.setFocusOnCloseNode( this );
return keyboardHelpDialog;
}, [], {
tandem: tandem.createTandem( 'keyboardHelpDialogCapsule' ),
phetioType: PhetioCapsule.PhetioCapsuleIO( Dialog.DialogIO )
} );
...
options.listener = () => {
const keyboardHelpDialog = keyboardHelpDialogCapsule.getElement();
keyboardHelpDialog.show();
// if listener was fired because of accessibility
if ( this.isPDOMClicking() ) {
// focus the close button if the dialog is open with a keyboard
keyboardHelpDialog.focusCloseButton();
}
}; So is every client that creates an accessible Dialog expected to call |
I've added support for this in the above commits, in master and 1.0 branches. Here's the boilerplate that I had to add in 3 places to make this work: const dialog = new SomeDialog(...);
const button = new SomeButton( {
listener: () => {
dialog.show();
if ( button.isPDOMClicking() ) {
dialog.focusCloseButton();
}
},
...
} );
dialog.setFocusOnCloseNode( button ); @jessegreenberg is this the correct pattern? |
The change you made will work and matches what is currently supported by Dialog. And that should fly for 1.0 release. The pattern can generally be improved though and this can be handled in Dialog now. Checking the source of input with The right way forward is to focus the close button by default when the Dialog is opened but offer an option to focus something else instead. |
Thanks @jessegreenberg. I removed the unnecessary calls to Oh rats... I found another dialog that I need to handle, the Info dialog for Wave Game screen. |
Wave Game info dialog is handled in the above commits, for master and 1.0. |
Slack conversation with @jessegreenberg Chris Malley 3:13 PM if ( infoButton.isPDOMClicking() ) {
infoDialog.focusCloseButton();
} … instead of simply calling Jesse Greenberg 3:16 PM Chris Malley 3:18 PM |
@pixelzoom should the change be made for each amplitude box as well? ? |
Absolutely, good catch @Nancy-Salpepi. |
@zepumph please let me know when phetsims/sun#719 is closed, so that I can proceed with this issue. |
Focus is not behaving as desired for RewardDialog, see phetsims/vegas#96 (comment). So unchecking those checklist items in #194 (comment), and on-hold until that issue is closed. |
I reviewed the common code issue over in phetsims/sun#719 (comment). Unassigning. |
Looks like there's still significant work to be done in phetsims/sun#719, so still on-hold until that is completed. In the meantime, I'm not going to attempt to cherry-pick anything related to phetsims/sun#719. |
I discussed the RewardDialog with @arouinfar via Zoom. She's OK with publishing with the current behavior, so we'll consider the issue closed for Fourier 1.0. And I'll check off the related items in #194 (comment). The current implementation of |
phetsims/sun#719 has been reviewed and I collected a list of changes to cherry-pick in phetsims/sun#719 (comment) so this is no longer on hold. |
Cherry-picks identified in phetsims/sun#719 (comment) have been completed and patched into Fourier 1.0 branch. This is ready for verification in the next RC. This has been a long, complicated issue, so I'll need to summarize what and how to verify. |
To verify in the next RC, test each of these scenarios. You may want to reload the sim for each scenario.
|
@pixelzoom When I tab the traversal order is: New Level > Keep Going > first open tab in browser > tab repeatedly through everything at the top of the browser > close (X) button If that is what you meant, then this issue is ready to be closed. |
@Nancy-Salpepi this is the browser's address bar, where you type in URLs.
That's a bit unexpected. When I test in Chrome and Safari, the only part of the browser that gets focus is the address bar. I'm not forced to tab through any other browser controls. I'll assign to @pixelzoom to investigate. |
Sorry for the confusion by saying "browser url textfield", that specific location isn't important. What is important is that after the last focusable sim component focus goes to browser controls (whatever those may be) before going back to the first focusable element in the sim. Firefox has decided that all tabs and bookmarks are in their traversal order and that is not something that we can control. |
Thanks @jessegreenberg. I was actually on Mac + chrome not Firefox. |
Test device
MacBook Air (m1 chip)
Operating System
11.6
Browser
chrome
Problem description
phetsims/qa#711
When using keyboard nav, the close (X) button is already highlighted when the Keyboard Shortcuts dialog is opened. However, when the Info and Expand Sum dialogs are opened, it is not. This prevents the user from being able to hit "esc" to exit. In those instances, the "tab" button must first be pressed and then either "esc" or "space bar" to exit.
Visuals
Troubleshooting information:
!!!!! DO NOT EDIT !!!!!
Name: Fourier: Making Waves
URL: https://phet-dev.colorado.edu/html/fourier-making-waves/1.0.0-rc.1/phet/fourier-making-waves_all_phet.html
Version: 1.0.0-rc.1 2021-09-28 15:44:23 UTC
Features missing: applicationcache, applicationcache, touch
Flags: pixelRatioScaling
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36
Language: en-US
Window: 1391x690
Pixel Ratio: 2/1
WebGL: WebGL 1.0 (OpenGL ES 2.0 Chromium)
GLSL: WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)
Vendor: WebKit (WebKit WebGL)
Vertex: attribs: 16 varying: 31 uniform: 1024
Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 80)
Max viewport: 16384x16384
OES_texture_float: true
Dependencies JSON: {}
The text was updated successfully, but these errors were encountered: