Skip to content

Commit

Permalink
Merge pull request #60 from PolymerElements/one-ripple-space-down
Browse files Browse the repository at this point in the history
At most one ripple when the space key is held down
  • Loading branch information
keanulee committed Jan 29, 2016
2 parents 6ca2e65 + 58f6920 commit 5374dc6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion paper-button-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
*/
_spaceKeyDownHandler: function(event) {
Polymer.IronButtonStateImpl._spaceKeyDownHandler.call(this, event);
if (this.hasRipple()) {
// Ensure that there is at most one ripple when the space key is held down.
if (this.hasRipple() && this.getRipple().ripples.length < 1) {
this._ripple.uiDownAction();
}
},
Expand Down
28 changes: 28 additions & 0 deletions test/paper-button-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,34 @@
assert.equal(button.elevation, 3);
assert.ok(button.hasRipple());
});

test('space key', function(done) {
const SPACE_KEY_CODE = 32;
var ripple;
MockInteractions.focus(button);

assert.ok(button.hasRipple());

ripple = button.getRipple();
MockInteractions.keyDownOn(button, SPACE_KEY_CODE);

assert.equal(ripple.ripples.length, 1);

MockInteractions.keyDownOn(button, SPACE_KEY_CODE);

assert.equal(ripple.ripples.length, 1);

MockInteractions.keyUpOn(button, SPACE_KEY_CODE);

var transitionEndCalled = false;
ripple.addEventListener('transitionend', function() {
if (!transitionEndCalled) {
transitionEndCalled = true;
assert.equal(ripple.ripples.length, 0);
done();
}
});
});
});
</script>

Expand Down

0 comments on commit 5374dc6

Please sign in to comment.