Skip to content

fix(material/datepicker): avoid interfering with external click listener #21856

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

Merged

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Feb 9, 2021

Currently the datepicker toggle's click listener is on the inner button element and we call stopPropagation on it in order to prevent the form field from focusing the input. The problem is that doing so will also prevent any custom click handler that the user might have added to the mat-datepicker-toggle.

These changes resolve the issue by moving the listener directly onto the toggle host which will invoke any external listeners while still allowing us to stop its propagation.

Fixes #21836.

Currently the datepicker toggle's `click` listener is on the inner `button` element and we
call `stopPropagation` on it in order to prevent the form field from focusing the input.
The problem is that doing so will also prevent any custom `click` handler that the user
might have added to the `mat-datepicker-toggle`.

These changes resolve the issue by moving the listener directly onto the toggle host
which will invoke any external listeners while still allowing us to stop its propagation.

Fixes angular#21836.
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release labels Feb 9, 2021
@crisbeto crisbeto requested a review from mmalerba as a code owner February 9, 2021 20:20
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 9, 2021
@crisbeto crisbeto added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Feb 9, 2021
@crisbeto
Copy link
Member Author

crisbeto commented Feb 9, 2021

Caretaker note: this has a slight chance of breaking people's tests. If there are any issues during the presubmit, we should re-evaluate the PR.

Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Feb 10, 2021
@mmalerba mmalerba merged commit deebaae into angular:master Feb 12, 2021
mmalerba pushed a commit that referenced this pull request Feb 12, 2021
…ner (#21856)

Currently the datepicker toggle's `click` listener is on the inner `button` element and we
call `stopPropagation` on it in order to prevent the form field from focusing the input.
The problem is that doing so will also prevent any custom `click` handler that the user
might have added to the `mat-datepicker-toggle`.

These changes resolve the issue by moving the listener directly onto the toggle host
which will invoke any external listeners while still allowing us to stop its propagation.

Fixes #21836.

(cherry picked from commit deebaae)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(MatDatepicker): Add pass-through change and click events to MatDatepickerToggle
2 participants