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

Fix getActiveDialog to accept different appendTo values #558

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix getActiveDialog to accept different appendTo values #558

wants to merge 1 commit into from

Conversation

acalvo
Copy link

@acalvo acalvo commented Jun 26, 2017

The getActiveDialog private function is currently used to handle the TAB key in case trapFocus is true. The function returns the last '.ngdialog' in the DOM, which is normally the active dialog, but as noted in a comment in the source code, this doesn't work in case of mixed 'appendTo' values. You might be opening a second dialog somewhere before in the DOM which is actually the active one, because due to a higher z-index value it's the one being shown on the top.

This caused the TAB key not to work properly in those cases of mixed 'appendTo' values. Here's a demo of the problem: https://jsfiddle.net/r6fr5wz0/
Click on "open second dialog" and then press TAB. The result will be that the focus goes back to the first dialog (as it is the active one according to getActiveDialog for being the latest in the DOM) while the expected behaviour would be to stay in the second one.

My PR fixes this problem. It goes over the openIdStack getting the highest z-index. In case it's the same among two dialogs, then it checks the order in the DOM. This makes getActiveDialog always return the topmost dialog.

The previous demo with my PR applied: https://jsfiddle.net/55jwo3sb/

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

Successfully merging this pull request may close these issues.

1 participant