bug(DatePicker): Focus Handling does not work with Shadow DOM #21785
Labels
area: material/datepicker
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Reproduction
Stackblitz Demo: https://stackblitz.com/edit/components-issue-mlorwc?file=src/app/example-component.html
GitHub Repo: https://github.com/zie-rts/mat-datepicker-shadow-dom
The Stackblitz demo does not use custom elements (it did not work) and does not have any styling.
The GitHub repo uses custom elements, has some styling and also shows that the element is focused.
Steps to reproduce:
Step 2/3: Instead of clicking the datepicker button you can also focus the input element and press Alt+Arrow Down to open the calender and use the keyboard to select a date.
Expected Behavior
The previous focused element should be focused again.
That's either the datepicker button or the input element.
Actual Behavior
Angular Material sets the focus to the element that was previously focused.
If the datepicker field is used inside Shadow DOM the shadow root element will be focused. As this will not be focusable most of the time the body element will receive the focus. If we set tabindex="-1" on the element we can see that the element gets the focus (see GitHub repo).
Environment
The text was updated successfully, but these errors were encountered: