From bcf58e534ee0514fdfc85ea210a11b247b8b6f87 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Wed, 22 Apr 2026 12:08:58 +0200 Subject: [PATCH] fix(material/select): open handler invoked twice Fixes that the select's `open` handler was being called twice: once from the trigger's `click` handler and once from the `onContainerClick` callback when the event propagates. Fixes #33116. --- goldens/material/select/index.api.md | 2 ++ src/material/select/select.html | 2 +- src/material/select/select.ts | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/goldens/material/select/index.api.md b/goldens/material/select/index.api.md index 58da7072077a..ce39f53d3460 100644 --- a/goldens/material/select/index.api.md +++ b/goldens/material/select/index.api.md @@ -361,6 +361,8 @@ export class MatSelect implements AfterContentInit, OnChanges, OnDestroy, OnInit tabIndex: number; toggle(): void; trigger: ElementRef; + // (undocumented) + protected _triggerClicked(): void; get triggerValue(): string; typeaheadDebounceInterval: number; updateErrorState(): void; diff --git a/src/material/select/select.html b/src/material/select/select.html index d31f2c834ecd..36de11f73b7d 100644 --- a/src/material/select/select.html +++ b/src/material/select/select.html @@ -1,7 +1,7 @@
diff --git a/src/material/select/select.ts b/src/material/select/select.ts index 94efdfec1f28..d94410574828 100644 --- a/src/material/select/select.ts +++ b/src/material/select/select.ts @@ -1018,6 +1018,13 @@ export class MatSelect return !this._selectionModel || this._selectionModel.isEmpty(); } + protected _triggerClicked() { + // If a parent form field is present, it'll pick up this click so we don't need to handle it. + if (!this._parentFormField) { + this.open(); + } + } + private _initializeSelection(): void { // Defer setting the value in order to avoid the "Expression // has changed after it was checked" errors from Angular.