-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
bug(TimepickerInput): Incorrect input behavior when component is in shadow DOM #30641
Labels
area: material/timepicker
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Comments
calebkish
pushed a commit
to calebkish/components
that referenced
this issue
Mar 17, 2025
…matting Fixes an issue where the value of the input element referenced by a TimepickerInput component inside a shadow DOM was getting formatted too often due to `TimepickerInput._hasFocus()` assuming the component wasn't in the shadow DOM. Fixes angular#30641
calebkish
pushed a commit
to calebkish/components
that referenced
this issue
Mar 17, 2025
Fixes an issue where the value of the input element referenced by a TimepickerInput component inside a shadow DOM was getting formatted too often due to `TimepickerInput._hasFocus()` assuming the component wasn't in the shadow DOM. Fixes angular#30641
calebkish
pushed a commit
to calebkish/components
that referenced
this issue
Mar 17, 2025
Fixes an issue where the value of the input element referenced by a TimepickerInput component inside a shadow DOM was getting formatted too often due to `TimepickerInput._hasFocus()` assuming the component wasn't in the shadow DOM. Fixes angular#30641
calebkish
pushed a commit
to calebkish/components
that referenced
this issue
Mar 17, 2025
Fixes an issue where the value of the input element referenced by a TimepickerInput component inside a shadow DOM was getting formatted too often due to `TimepickerInput._hasFocus()` assuming the component wasn't in the shadow DOM. Fixes angular#30641
calebkish
pushed a commit
to calebkish/components
that referenced
this issue
Mar 19, 2025
Fixes an issue where the value of the input element referenced by a TimepickerInput component inside a shadow DOM was getting formatted too often due to `TimepickerInput._hasFocus()` assuming the component wasn't in the shadow DOM. Fixes angular#30641
crisbeto
pushed a commit
that referenced
this issue
Mar 19, 2025
…0642) Fixes an issue where the value of the input element referenced by a TimepickerInput component inside a shadow DOM was getting formatted too often due to `TimepickerInput._hasFocus()` assuming the component wasn't in the shadow DOM. Fixes #30641 Co-authored-by: Caleb Kish <j69674031@gmail.com> (cherry picked from commit ee44255)
mistrykaran91
pushed a commit
to mistrykaran91/components
that referenced
this issue
Mar 20, 2025
…gular#30642) Fixes an issue where the value of the input element referenced by a TimepickerInput component inside a shadow DOM was getting formatted too often due to `TimepickerInput._hasFocus()` assuming the component wasn't in the shadow DOM. Fixes angular#30641 Co-authored-by: Caleb Kish <j69674031@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: material/timepicker
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Is this a regression?
The previous version in which this bug was not present was
No response
Description
When the
MatTimepickerInput
component is within a shadow DOM, the input element's value will get formatted more often than it should, which results in unexpected behavior when typing.The reason for this is
MatTimepickerInput._hasFocus()
making the assumption that the component will never be in the shadow DOM, doing a check thatinject(DOCUMENT).activeElement === inject(ElementRef).nativeElement
.inject(DOCUMENT)
refers to the root document, so when theMatTimepickerInput
component instance is in the shadow DOM, the check thatMatTimepickerInput._hasFocus()
is doing will never betrue
.The comparison that should actually be done is
inject(ElementRef).nativeElement.getRootNode().activeElement === inject(ElementRef).nativeElement
.Reproduction
StackBlitz link: https://stackblitz.com/edit/components-issue-starter-ucheqywm?file=src%2Fmain.ts
Steps to reproduce:
Expected Behavior
The expected behavior is typing "12:30 PM", and the "12:30 PM" option being selected.
Actual Behavior
Environment
The text was updated successfully, but these errors were encountered: