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

Prevent restoring focus to last element if none exist #217

Open
wants to merge 2 commits into
base: 0.3
Choose a base branch
from

Conversation

rhuynh
Copy link

@rhuynh rhuynh commented Apr 11, 2014

Fixed a null pointer exception when trying to restore focus to the last element where that element doesn't exist.

Fixed a null pointer exception when trying to restore focus to the last element where that element doesn't exist.
@rhuynh
Copy link
Author

rhuynh commented Apr 11, 2014

There is a specific case where this bug exists in ie11. In my application, if you trigger the alertify dialog as a result of a button and you remove that button from the dom, when you click on the dialog ok button, you will get the exception as elCallee === null. This is due to document.activeElement will sometime be null.

@@ -419,7 +419,9 @@
elCover.className = "alertify-cover alertify-cover-hidden";
// set focus to the last element or body
// after the dialog is closed
elCallee.focus();
if (elCallee) {
elCallee.focus();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts on a fallback to reset the tabbing focus at the top of the page instead of the bottom?

if (elCallee) {
    elCallee.focus();
} else {
    document.body.focus();
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have thought about that option, but what i found is that the browser will show the focus border around the body and it does seem kinda strange/annoying since the user didn't trigger the alertrify from the body (i know that you can hide this w/ css, but it seems unnecessary). is it necessary to always reset the focus back to some element after the dialog is closed?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary to always reset the focus back to some element after the dialog is closed?

Nope. I was just curious!

If you could just squash your commits, I'll merge. Thanks

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.

2 participants