Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App drawer causes auto focus on the first focuseable element from its content #437

Closed
8 tasks
alexui opened this issue Mar 24, 2017 · 4 comments
Closed
8 tasks

Comments

@alexui
Copy link

alexui commented Mar 24, 2017

Description

App-drawer causes auto focus on the first focuseable element from its content

<app-drawer id="drawer" align="right">
<app-toolbar>
<paper-icon-button id="close-drawer-button" icon="someIcon"></paper-icon-button>
</app-toolbar>
<paper-menu id="drawer-menu" tabindex="-1" selected="[[tabSelected]]">
<template is="dom-repeat" items="{{menuItems}}">
<paper-item id="{{item.name}}" name$="{{item.name}}">{{item.value}}</paper-item>
</template>
</paper-menu>
</app-drawer>

The problem is that the <paper-icon-button id="close-drawer-button"> is focused when I open the drawer. If I disable the button the next focuseable element is focused.
How to disable autofocus?

Browsers Affected

  • Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10
@KevinAsher
Copy link

KevinAsher commented Mar 24, 2017

Try setting the attribute no-focus-trap="true" on app-drawer.
Docs: https://www.webcomponents.org/element/PolymerElements/app-layout/app-drawer#property-noFocusTrap

@alexui
Copy link
Author

alexui commented Mar 26, 2017

It works. Thank you very much.

@alexui alexui closed this as completed Mar 26, 2017
@dimon-durak
Copy link

dimon-durak commented Jan 31, 2018

@KevinAsher disabling focus by attribute no-focus-trap work well

But, how manually set focused element from js?

For example, in PSK drawer always focused first element. I try manually set focus for selected anchor in _pageChanged, but still focused first element.

_pageChanged(page) {
  let link = this.$.drawer.querySelector(`a.iron-selected`);
  if (link) link.focus();
  
  // other code here

@keanulee
Copy link
Contributor

You can try using the app-drawer-transitioned event - this is fired in the same function that sets the keyboard focus trap (https://github.com/PolymerElements/app-layout/blob/master/app-drawer/app-drawer.html#L574).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants