Enable specifying elements which can be focused #11686
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A modal dialog does not enable any element which is not a descendant of the dialog to recieve focus.
This makes a lot of sense, of course but it also creates undesriable behavior in extreme cases where controls have elements which are direct descendants of the body element.
For example, drop down elements are usually descendants of the body element and therefore does not behave nicely inside dialogs.
Related issues (drop down inside bootstrap modal dialog does not recieve focus):
I found many discussions on this issue and no final solution.
However, I did find that the same problem existed in JQuery dialog and it solution (described here: https://github.com/ivaynberg/select2/issues/1246).
The idea is that the dialog exposes a method which enables the client to specify whether the element can recieve focus or not.
My change does exactly that: added an
allowFocus
method which is called from theenforceFocus
method. IfallowFocus
returnstrue
focus will not be enforced by the dialog.The usage for enabling
select2
dropdown to recieve focus is as follows: