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: Focus on correct element when entering fullscreen in Firefox #864

Merged
merged 3 commits into from
Nov 16, 2018
Merged

Fix: Focus on correct element when entering fullscreen in Firefox #864

merged 3 commits into from
Nov 16, 2018

Conversation

jeremypress
Copy link
Contributor

No description provided.

@boxcla
Copy link

boxcla commented Nov 15, 2018

Verified that @jeremypress has signed the CLA. Thanks for the pull request!

@jeremypress
Copy link
Contributor Author

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.

// 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) {
Copy link
Contributor

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)

// 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 {
Copy link
Collaborator

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();

@jeremypress jeremypress merged commit 3d7cf79 into box:master Nov 16, 2018
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.

4 participants