mat-select doesn't propagate (change) event to containing div
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
mat-select
as opposed to usual select
does not propagate the onChange
event up the hierarchy. If we have a div
container for this mat-select then (change)
event on the div will not be captured.
Whereas, the mat-select
tag itself obviously captures the change
event.
Also, form
it is contained in updates the class to ng-dirty
, but somehow the div
is unable to capture the event. The usual select
gives the right behavior.
What is the current behavior?
The mat-select
change
event must be propagated to the containing div
as happens in normal select
dropdown.
What are the steps to reproduce?
https://stackblitz.com/edit/angular-material2-issue-xdzlo7
What is the use-case or motivation for changing an existing behavior?
Even should propagate
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular- 5.2.0
Angular Material 5.2.4
Os- Linux
Typescript- 2.5.3
Browser- Chrome
Is there anything else we should know?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How can I stopPropagation when angular mat-select option ...
Wrap the mat-select with a div. That can be used to capture and stop the same click event that triggers the mat-select selection....
Read more >stopPropagation() Event Method - W3Schools
The stopPropagation() method prevents propagation of the same event from being called. Propagation means bubbling up to parent elements or capturing down to ......
Read more >mat-select change event angular 7
mat-select as opposed to usual select does not propagate the onChange event up the hierarchy. If we have a div container for this...
Read more >Overlay | Angular Material
Container inside which all overlays will render. ... This method returns the overlay container element. ... Event emitted when the position has changed....
Read more >Material Select Change Event - StackBlitz
<div class="basic-container"> ... <mat-select placeholder="Favorite food" [. (ngModel)]="selectedFood1" (change) ... <mat-hint>(change) event</mat-hint>.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
change
event onselect
is a native DOM event, whereasmat-select
doesn’t have achange
event at all. It has aselectionChange
event which is anEventEmitter
and which won’t bubble up the DOM.You need to use (selectionChange) instead of (change). (change) is deprecated from angular 6.0 Solution to this: https://github.com/angular/material2/issues/11786