Last active
February 5, 2021 13:27
-
-
Save stephband/115b0307940989c79c9306ca49f95d4b to your computer and use it in GitHub Desktop.
Log activeElement on focus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('focusin', (e) => | |
// Sanity check for target being activeElement, should always be true | |
console.log('focusin', e.target === document.activeElement, document.activeElement) | |
); | |
document.addEventListener('focusout', (e) => | |
// Sanity check that activeElement is body, should always be true | |
console.log('focusout', document.body === document.activeElement) | |
); |
On firefox, if label doesn't have tabindex, it just skips.
And this doesn't seem to help... the input gets focus before the link, but the label still does not seem to focus the input.
<input type="radio" id="x" />
<a href="#some-other-focusable-thing">...</a>
<label for="x" ... >...</label>
Yes, on Chrome too.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@halitcelik > What I read is that label gets focus but forwards it to input.
Interesting. But look:
The label gets focus, but hitting enter does not check the radio.