Refocusing window restores previous keyboard-focused state #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initial PR, but do not merge yet — there's an open question about unit tests below.
This is a proposed fix for PolymerElements/paper-button#24.
To summarize what I believe is the desired behavior:
It seems that all buttons should exhibit this behavior, not just
paper-button
, so this PR proposes making the fix in iron-button-state. (If that seems correct, I can move the issue to iron-button-state.)The PR fixes the issue by:
This PR opportunistically fixes a related, subtle bug in keyboard/pointer focus rendering: if the user switches input modalities while a button has focus, the button's keyboard/pointer focus rendering updates to match the latest modality. If the user presses down on a button with a pointer, then press Space or Enter, the keyboard focus rendering is applied. Conversely, if the user tabs to a button with the keyboard, but then presses the button with a pointer, the keyboard rendering is dropped.
At this point, the core functionality appears to work in interactive testing of paper-button, paper-checkbox, and paper-radio-button, but I'd like recommendations on unit testing this. All existing unit tests pass, but the PR does not yet include unit tests for the new behavior. The new behavior is implicated in window-level blur/focus events, which are not possible to directly test in unit tests, nor does there appear to be support for mock window blur/focus events.