-
Notifications
You must be signed in to change notification settings - Fork 28
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 the selected tab from being refocused when local DOM elements of the menu are focused. #36
Conversation
785baa9
to
1b97a7f
Compare
1b97a7f
to
6edd314
Compare
var menu = fixture('basic'); | ||
menu.extraContent.focus(); | ||
setTimeout(function() { | ||
var menuActiveElement = Polymer.dom(menu.root).querySelector('*:focus'); |
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.
:focus
should work fine for this, FWIW.
(needs Polymer/polymer#2717) |
// Do not focus the selected tab if the deepest target is part of the | ||
// menu element's local DOM and is focusable. | ||
var rootTarget = Polymer.dom(event).rootTarget; | ||
if (rootTarget !== this && !this.isLightDescendant(rootTarget) && rootTarget.hasAttribute('tabindex')) { |
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.
It may be slightly faster to measure tabindex using the property syntax. Also on the subject of micro-optimization, it might be good to check for rootTarget.tabindex
before this.isLightDescendant
, so that we can short-circuit before the relatively more expensive check.
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.
Fixed.
Left some feedback, PTAL! |
Fixed up the stuff you mentioned. |
@bicknellr please rebase this PR ⚾ |
e76b170
to
e3bc400
Compare
Man, what happened to the test suite here? Looks like a lot of broken 💩 .. |
@cdata The tests use |
e3bc400
to
b3ad13f
Compare
Polymer/polymer#2717 is in. I |
b3ad13f
to
33ea777
Compare
@cdata, Polymer/polymer#2717 is now in a release. |
…the menu are focused.
… tests for `activeElement`.
fd90fb1
to
529afb4
Compare
Ship it! |
…e-65 Prevent the selected tab from being refocused when local DOM elements of the menu are focused.
Fixes PolymerElements/paper-tabs#65.