Skip to content

Commit

Permalink
allow configuring restore-focus-on-close (#94)
Browse files Browse the repository at this point in the history
* allow configuring restore-focus-on-close

* add doc comment

* test that restoreFocusOnClose propagates to dropdown

* shave some indent and re-order property after merging

* the OCD is taking hold

* srsly
  • Loading branch information
danbeam authored and valdrinkoshi committed Jul 21, 2016
1 parent c416130 commit 50477ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion paper-menu-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
no-animations="[[noAnimations]]"
focus-target="[[_dropdownContent]]"
allow-outside-scroll="[[allowOutsideScroll]]"
restore-focus-on-close
restore-focus-on-close="[[restoreFocusOnClose]]"
on-iron-overlay-canceled="__onIronOverlayCanceled">
<div class="dropdown-content">
<content id="content" select=".dropdown-content"></content>
Expand Down Expand Up @@ -330,6 +330,14 @@
value: false
},

/**
* Whether focus should be restored to the button when the menu closes.
*/
restoreFocusOnClose: {
type: Boolean,
value: true
},

/**
* This is the element intended to be bound as the focus target
* for the `iron-dropdown` contained by `paper-menu-button`.
Expand Down
7 changes: 7 additions & 0 deletions test/paper-menu-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@
expect(menuButton.$.dropdown.allowOutsideScroll).to.be.equal(true);
});

test('restoreFocusOnClose propagates to <iron-dropdown>', function() {
menuButton.restoreFocusOnClose = false;
expect(menuButton.$.dropdown.restoreFocusOnClose).to.be.equal(false);
menuButton.restoreFocusOnClose = true;
expect(menuButton.$.dropdown.restoreFocusOnClose).to.be.equal(true);
});

});

suite('when there are two buttons', function() {
Expand Down

0 comments on commit 50477ec

Please sign in to comment.