-
Notifications
You must be signed in to change notification settings - Fork 116
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: Focus on correct element when entering fullscreen in Firefox #864
Conversation
Verified that @jeremypress has signed the CLA. Thanks for the pull request! |
Let me know if it's more clear when breaking the cases out like this. If it's too verbose I can move it back to a one liner. |
src/lib/Fullscreen.js
Outdated
// Focus on the fullscreen element so keyboard | ||
// events are triggered without an extra click | ||
// If el has target property, then it is an Event | ||
// otherwise it is a HTMLElement | ||
const element = el.target || el; | ||
let element; | ||
if (elementOrEvent.target) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you maybe use getProp
here? Something like getProp(elementOrEvent, 'target.activeElement', elementOrEvent)
src/lib/Fullscreen.js
Outdated
// This is an element | ||
// On certain browsers (Firefox), the actual target is on the activeElement property of the event target | ||
element = elementOrEvent.target.activeElement || elementOrEvent.target; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could simplify this a bit by avoiding the else
clause here.
let element = elementOrEvent;
// Comment explaining why this may sometimes be an event instead of an element
if (element.target) {
element = // etc.
}
element.focus();
No description provided.