This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23405 - <dialog>: When a modal <dialog> is closed, focus should return to where it was when the dialog was shown
Summary: <dialog>: When a modal <dialog> is closed, focus should return to where it wa...
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on: 23475
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-01 05:46 UTC by Matt Falkenhagen
Modified: 2014-03-12 23:09 UTC (History)
4 users (show)

See Also:


Attachments

Description Matt Falkenhagen 2013-10-01 05:46:23 UTC
Looks like this would be a nice addition for accessibility:
https://code.google.com/p/chromium/issues/detail?id=264959#c4

Otherwise, in Chrome currently, focus resets back up to document.body and you must manually navigate back to where you were before the dialog opened.

window.showModalDialog() gets this behavior for free because it doesn't disrupt the focus of the original document when it opens a new window.

One detail is what to do if the element that had focus no longer exists or is not focusable. I guess we can reset to document.body in that case.

Related is bug 23365, bug 23366
Comment 1 Ian 'Hixie' Hickson 2013-10-01 20:30:57 UTC
Seems reasonable.
Comment 2 Ian 'Hixie' Hickson 2013-11-20 23:02:09 UTC
I think we probably actually want to never unfocus the element with control focus when a new <dialog> is given window focus. We probably just want each <dialog>, and the top-level Document, to have its own concept of the focused control.
Comment 3 Ian 'Hixie' Hickson 2013-12-10 23:14:57 UTC
This is going to fall out of bug 23475 for free, I think.
Comment 4 Ian 'Hixie' Hickson 2014-03-12 23:09:25 UTC
Yup, this just ended up working automatically.