Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e3f886c

Browse files
committed
refactor(material/select): account for popovers
Updates the select to account for the fact that when its overlay is rendered in a popover, the event bubbling order is different.
1 parent 5e39b48 commit e3f886c

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

‎goldens/material/select/index.api.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export class MatSelect implements AfterContentInit, OnChanges, OnDestroy, OnInit
316316
ngOnInit(): void;
317317
_onBlur(): void;
318318
_onChange: (value: any) => void;
319-
onContainerClick(): void;
319+
onContainerClick(event:MouseEvent): void;
320320
// (undocumented)
321321
_onFocus(): void;
322322
_onTouched: () => void;

‎src/material/select/select.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import {
7171
NgForm,
7272
Validators,
7373
} from '@angular/forms';
74+
import {_getEventTarget} from '@angular/cdk/platform';
7475
import {
7576
_animationsDisabled,
7677
_countGroupLabelsBeforeOption,
@@ -1461,20 +1462,27 @@ export class MatSelect
14611462
* @docs-private
14621463
*/
14631464
setDescribedByIds(ids: string[]) {
1465+
const element = this._elementRef.nativeElement;
1466+
14641467
if (ids.length) {
1465-
this._elementRef.nativeElement.setAttribute('aria-describedby', ids.join(' '));
1468+
element.setAttribute('aria-describedby', ids.join(' '));
14661469
} else {
1467-
this._elementRef.nativeElement.removeAttribute('aria-describedby');
1470+
element.removeAttribute('aria-describedby');
14681471
}
14691472
}
14701473

14711474
/**
14721475
* Implemented as part of MatFormFieldControl.
14731476
* @docs-private
14741477
*/
1475-
onContainerClick() {
1476-
this.focus();
1477-
this.open();
1478+
onContainerClick(event: MouseEvent) {
1479+
const target = _getEventTarget(event) as Node | null;
1480+
const overlayHost = this._overlayDir.overlayRef?.hostElement;
1481+
1482+
if (!target || !overlayHost || !overlayHost.contains(target)) {
1483+
this.focus();
1484+
this.open();
1485+
}
14781486
}
14791487

14801488
/**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /