-
-
Notifications
You must be signed in to change notification settings - Fork 114
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 management on open / close #375
Comments
So, I'll try to be as structured as possible(all is personal opinion):
|
Maybe we can have an interface for this, say interface IFocusManager {
// return element to be focused when this dialog is closed
// return null means don't focus anything?
onDialogOpen(lastActiveElement: HTMLElement): HTMLElement;
// only invoked when onDialogOpen returns an element?
// return null means don't focus anything?
onDialogClosed(toBeFocusedElement: HTMLElement): HTMLElement;
} Basically when dealing with form, focus strategy may need to be more than just simple last blurred first focused. |
@bigopon I went for a simpler interface. If a developer wants to restore focus to a different element they can simply override the @StrahilKazlachev I went for a simple addition to both renderers. While I agree that the code could do with some refactoring, I think it's out of scope for this bug. |
Fixed in #378 |
I've been looking at the accessibility of the dialogs, notably whether they comply with the WAI-ARIA best practices for dialogs. The native renderer introduced in #338 helped a lot. Notably, it ensures focus is placed on the dialog when it opens and cannot leave the dialog. Perhaps similar functions should be added to the standard renderer to make it properly accessible, but that's not what I'm here for.
One accessibility problem remains and that is that focus is not properly returned to the underlying document when the dialog closes. This can make it very difficult to navigate using only a keyboard, and can result in very unclear situations for screenreaders.
The solution is pretty straight forward: the last focused element at the moment a dialog opens needs to be remembered, and focus should be returned to this element when it closes. If that element is no longer available, focus needs to be returned somewhere else in the document. This process needs to be overridable for specific dialogs, since the user may know a better place to return focus to once the dialog closes. See the WAI-ARIA notes as well.
The text was updated successfully, but these errors were encountered: