diff --git a/iron-button-state.html b/iron-button-state.html index 8114e2d..c5221b8 100644 --- a/iron-button-state.html +++ b/iron-button-state.html @@ -91,7 +91,7 @@ }, observers: [ - '_detectKeyboardFocus(focused)', + '_focusChanged(focused)', '_activeChanged(active, ariaActiveAttribute)' ], @@ -112,6 +112,14 @@ } }, + _focusChanged: function(focused) { + this._detectKeyboardFocus(focused); + + if (!focused) { + this._setPressed(false); + } + }, + _detectKeyboardFocus: function(focused) { this._setReceivedFocusFromKeyboard(!this.pointerDown && focused); }, diff --git a/test/active-state.html b/test/active-state.html index 8735aaf..e1ed479 100644 --- a/test/active-state.html +++ b/test/active-state.html @@ -125,6 +125,16 @@ }); }); }); + + suite('on blur', function() { + test('the pressed property becomes false', function() { + MockInteractions.focus(activeTarget); + MockInteractions.down(activeTarget); + expect(activeTarget.hasAttribute('pressed')).to.be.eql(true); + MockInteractions.blur(activeTarget); + expect(activeTarget.hasAttribute('pressed')).to.be.eql(false); + }); + }); }); suite('without toggles attribute', function() {