Skip to content

Commit 18b2239

Browse files
committed
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.
1 parent 91a4932 commit 18b2239

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

goldens/material/select/index.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ export class MatSelect implements AfterContentInit, OnChanges, OnDestroy, OnInit
361361
tabIndex: number;
362362
toggle(): void;
363363
trigger: ElementRef;
364+
// (undocumented)
365+
protected _triggerClicked(event: Event): void;
364366
get triggerValue(): string;
365367
typeaheadDebounceInterval: number;
366368
updateErrorState(): void;

src/material/select/select.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div
22
cdk-overlay-origin
33
class="mat-mdc-select-trigger"
4-
(click)="open()"
4+
(click)="_triggerClicked($event)"
55
#fallbackOverlayOrigin="cdkOverlayOrigin"
66
#trigger
77
>

src/material/select/select.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,12 @@ export class MatSelect
10181018
return !this._selectionModel || this._selectionModel.isEmpty();
10191019
}
10201020

1021+
protected _triggerClicked(event: Event) {
1022+
// Stop propagation so it doesn't reach `onContainerClicked`.
1023+
event.stopPropagation();
1024+
this.open();
1025+
}
1026+
10211027
private _initializeSelection(): void {
10221028
// Defer setting the value in order to avoid the "Expression
10231029
// has changed after it was checked" errors from Angular.

0 commit comments

Comments
 (0)