Prevent restoring focus to last element if none exist#217
Conversation
Fixed a null pointer exception when trying to restore focus to the last element where that element doesn't exist.
|
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. |
There was a problem hiding this comment.
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();
}There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Fixed a null pointer exception when trying to restore focus to the last element where that element doesn't exist.