Skip to content
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

Author control and possible race condition in dialog.close #6681

Closed
AutoSponge opened this issue May 12, 2021 · 3 comments
Closed

Author control and possible race condition in dialog.close #6681

AutoSponge opened this issue May 12, 2021 · 3 comments

Comments

@AutoSponge
Copy link

The following was a comment from #5678 as part of my action item from APA https://www.w3.org/WAI/APA/track/actions/2290:

The intent to manage focus of a closing dialog is a good one. However, if
authors have a clear understanding of the process they should have the
ability to change the focus target on dialog.close().

A common example: a dialog created for the "confirm delete" action with
"confirm" and "cancel" buttons. Cancel can target the default element per
this spec (i.e., the "delete" button). Confirm would send focus to
body since the deleted item no longer exists. An author should have the
ability to override this behavior but programmatically setting focus could
introduce a race condition with the default behavior.

Possible solutions:

  • the addition of a dialog property, with an idref value, that will
    override this behavior by targeting the specified element when present
    provided the element exists and is connected to the dom.
  • an options object or flag passed to dialog.close() that overrides the
    default behavior.
@domenic
Copy link
Member

domenic commented May 12, 2021

Why would there be a race condition? Just call focus after calling close (or after the close event fires). There's no race; things execute in order.

@AutoSponge
Copy link
Author

if

dialog.close();
document.getElementById('#myId').focus();

works across implementations, then I don't have an issue with a "possible race condition". That was in response to discussions about async events.

@sefeng211
Copy link
Contributor

sefeng211 commented May 12, 2021

The focusing the previously focused element step in dialog.close() is synchronous, and it should work across all implementations. So I don't think there's a race condition here?

Changing the default behaivour, ie not doing the steps is a different topic though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants