#8730 closed feature (fixed)
Dialog: Restore focus to opener
Reported by: | Jörn Zaefferer | 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.
Change History (5)
comment:1 Changed 10 years ago by
Priority: | minor → blocker |
---|---|
Status: | new → open |
comment:2 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
comment:3 follow-up: 4 Changed 8 years ago by
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?
comment:4 follow-up: 5 Changed 8 years ago by
Replying to 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.
comment:5 Changed 8 years ago by
Replying to scott.gonzalez:
Definitely a new issue. This is a two year old feature, it absolutely should not be used for anything at this point.
Ok, opened #10686, with real world use case and some rewording and other clarifications.
Dialog: Save the active element that opened the dialog and restore focus to that. Fixes #8730 - Dialog: Restore focus to opener.