Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

angular material (datepicker) focus is on body after any keyboard based operation #8960

Closed
eladh opened this issue Jul 6, 2016 · 3 comments
Assignees
Labels
has: Pull Request A PR has been created to address this issue type: bug

Comments

@eladh
Copy link

eladh commented Jul 6, 2016

Actual Behavior:

Its seems that ever keyboard based operation with the date-picker don't return the focus back to the date picker input or button.
As a result the tab indexing is back to the first element.

you can take example with the official demo:
looking at the sources and debugging - its seems that focus operation is triggered on the relevant element but even so - the focus changed to to the document body.

CodePen
https://material.angularjs.org/latest/demo/datepicker

Angular Versions: - latest

Additional Information:

  • Browser Type: * chrome
@crisbeto
Copy link
Member

crisbeto commented Jul 6, 2016

It seems to work when triggering from the input, but not from the buttons. Definitely a bug.

@crisbeto crisbeto self-assigned this Jul 6, 2016
@eladh
Copy link
Author

eladh commented Jul 6, 2016

Thanks @crisbeto
I must mention that the same behavior also happens on autocomplete when pressing escape - the active element is also changed the document body.

Thanks
elad.

@crisbeto
Copy link
Member

I had some time to look into this. I haven't found a good solution yet, but here's some info for future reference:

  1. The calendar icon doesn't refocus properly if the user clicks on the icon directly. It seems to be because the SVG element inside doesn't propagate the focus event. If the user clicks around the SVG, then refocusing works.
  2. I still haven't found what causes the body to be focused (it might be the backdrop after it's closed, or the calendar directive), but refocusing the triangle also works if it's wrapped in an rAF call.

crisbeto added a commit to crisbeto/material that referenced this issue Jul 19, 2016
* Fixes the datepicker not being able to refocus on the calendar icon, because the SVG element inside didn't propagate the focus event.
* Fixes the datepicker sometimes not refocusing on the element that triggered it.

Fixes angular#8960.
@crisbeto crisbeto added the has: Pull Request A PR has been created to address this issue label Jul 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has: Pull Request A PR has been created to address this issue type: bug
Projects
None yet
Development

No branches or pull requests

2 participants