Skip to content

Commit

Permalink
Merge pull request #106 from PolymerLabs/drawer-focus
Browse files Browse the repository at this point in the history
Default to no drawer focus trapping
  • Loading branch information
frankiefu committed Mar 9, 2016
2 parents 325d370 + fc86af3 commit 5a9c965
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions app-drawer/app-drawer.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,22 +221,11 @@
},

/**
* The CSS selector for the element that should receive focus when the drawer is open.
* By default, when the drawer opens, it focuses the first tabbable element. That is,
* the first element that can receive focus.
* If specified, the drawer will focus on this CSS selector when opened.
*/
focusSelector: {
type: String,
value:
'a[href]:not([tabindex="-1"]),' +
'area[href]:not([tabindex="-1"]),' +
'input:not([disabled]):not([tabindex="-1"]),' +
'select:not([disabled]):not([tabindex="-1"]),' +
'textarea:not([disabled]):not([tabindex="-1"]),' +
'button:not([disabled]):not([tabindex="-1"]),' +
'iframe:not([tabindex="-1"]),' +
'[tabindex]:not([tabindex="-1"]),' +
'[contentEditable=true]:not([tabindex="-1"])'
value: ''
}

},
Expand Down Expand Up @@ -335,6 +324,10 @@
},

_focusInsideDrawer: function() {
if (!this.focusSelector) {
return;
}

var child = Polymer.dom(this).querySelector(this.focusSelector);
if (child) {
child.focus();
Expand Down
2 changes: 1 addition & 1 deletion app-drawer/test/app-drawer.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<template>
<div>
<button id="toggle">Toggle</button>
<app-drawer>
<app-drawer focus-selector="#foo">
<button id="foo">Foo</button>
<button id="bar">Bar</button>
</app-drawer>
Expand Down

0 comments on commit 5a9c965

Please sign in to comment.