Search and Top Navigation
#8730 closed feature (fixed)
Opened October 24, 2012 09:01PM UTC
Closed October 24, 2012 09:05PM UTC
Last modified November 05, 2014 06:05PM UTC
Dialog: Restore focus to opener
Reported by: | jzaefferer | Owned by: | |
---|---|---|---|
Priority: | blocker | Milestone: | 1.10.0 |
Component: | ui.dialog | Version: | 1.9.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Whenever a dialog is opened, it should remember what element had focus, and restore focus to that element.
Attachments (0)
Change History (5)
Changed October 24, 2012 09:01PM UTC by comment:1
priority: | minor → blocker |
---|---|
status: | new → open |
Changed October 24, 2012 09:05PM UTC by comment:2
resolution: | → fixed |
---|---|
status: | open → closed |
Dialog: Save the active element that opened the dialog and restore focus to that. Fixes #8730 - Dialog: Restore focus to opener.
Changeset: 14691ae6feea2732ec5aeae57b4275aa0e4d1beb
Changed November 05, 2014 03:11PM UTC by comment:3
The current-implemented behavior can be an issue in cases where the dialog has been opened programmatically (e.g. triggered by some other event) and the originally-focused element ("opener" in the code, a misnomer in this case) is not visible within its scroll parent or the viewport.
Example:
http://jsfiddle.net/jzxseunh/1/
Closing the dialog will scroll the element into view even though it wasn't before.
The culprit is here:
https://github.com/jquery/jquery-ui/commit/14691ae#diff-bd5d7db0e6a3ff783a7ec2ccf261f6b4R251
The call to .focus() should not be done inside the conditional, but there should instead be a step to store the scrollTop/scrollLeft of the scroll parent just before the focus, then restore it after the focus (perhaps conditionally, depending on whether or not the element was already visible).
Does this sound reasonable? Should this be reopened, or should I copy-paste this as a new issue? Thoughts?
Changed November 05, 2014 03:19PM UTC by comment:4
Replying to [comment:3 usmonster]:
Does this sound reasonable?
So far, no, because you haven't provided a real world use case, though I'm sure you have one.
Should this be reopened, or should I copy-paste this as a new issue?
Definitely a new issue. This is a two year old feature, it absolutely should not be used for anything at this point.