Skip to content

Commit c14331f

Browse files
committed
.
1 parent fba0d56 commit c14331f

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

src/cdk/overlay/overlay-directives.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,10 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
362362
this._overlayRef.attach(this._templatePortal);
363363
this.attach.emit();
364364
}
365-
366-
if (this.hasBackdrop) {
367-
this._backdropSubscription = this._overlayRef.backdropClick().subscribe(event => {
368-
this.backdropClick.emit(event);
369-
});
370-
}
365+
366+
this._backdropSubscription = this._overlayRef.backdropClicks().subscribe(event => {
367+
this.backdropClick.emit(event);
368+
});
371369
}
372370

373371
/** Detaches the overlay and unsubscribes to backdrop clicks if backdrop exists */

src/cdk/overlay/overlay-ref.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class OverlayRef implements PortalOutlet {
111111
this._togglePointerEvents(true);
112112

113113
if (this._config.hasBackdrop) {
114-
this._attachBackdrop();
114+
this.attachBackdrop();
115115
}
116116

117117
if (this._config.panelClass) {
@@ -200,6 +200,10 @@ export class OverlayRef implements PortalOutlet {
200200
return this._portalOutlet.hasAttached();
201201
}
202202

203+
backdropClicks() {
204+
return this._backdropClick;
205+
}
206+
203207
/** Gets an observable that emits when the backdrop has been clicked. */
204208
backdropClick(): Observable<MouseEvent> {
205209
return this._backdropClick.asObservable();
@@ -280,7 +284,7 @@ export class OverlayRef implements PortalOutlet {
280284
}
281285

282286
/** Attaches a backdrop for this overlay. */
283-
private _attachBackdrop() {
287+
attachBackdrop() {
284288
const showingClass = 'cdk-overlay-backdrop-showing';
285289

286290
this._backdropElement = this._document.createElement('div');

src/lib/select/select.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<ng-template
1919
cdk-connected-overlay
2020
cdkConnectedOverlayLockPosition
21-
cdkConnectedOverlayHasBackdrop
2221
cdkConnectedOverlayOpen
2322
cdkConnectedOverlayDisableClose
2423
cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"

src/lib/select/select.spec.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ describe('MatSelect', () => {
395395
it('should open the panel when pressing a vertical arrow key on a closed multiple select',
396396
fakeAsync(() => {
397397
fixture.destroy();
398-
flush();
399398

400399
const multiFixture = TestBed.createComponent(MultiSelect);
401400
const instance = multiFixture.componentInstance;
@@ -421,7 +420,6 @@ describe('MatSelect', () => {
421420
it('should open the panel when pressing a horizontal arrow key on closed multiple select',
422421
fakeAsync(() => {
423422
fixture.destroy();
424-
flush();
425423

426424
const multiFixture = TestBed.createComponent(MultiSelect);
427425
const instance = multiFixture.componentInstance;
@@ -442,7 +440,6 @@ describe('MatSelect', () => {
442440

443441
it('should do nothing when typing on a closed multi-select', fakeAsync(() => {
444442
fixture.destroy();
445-
flush();
446443

447444
const multiFixture = TestBed.createComponent(MultiSelect);
448445
const instance = multiFixture.componentInstance;
@@ -488,7 +485,6 @@ describe('MatSelect', () => {
488485
it('should not shift focus when the selected options are updated programmatically ' +
489486
'in a multi select', fakeAsync(() => {
490487
fixture.destroy();
491-
flush();
492488

493489
const multiFixture = TestBed.createComponent(MultiSelect);
494490

@@ -537,7 +533,6 @@ describe('MatSelect', () => {
537533

538534
it('should not open a multiple select when tabbing through', fakeAsync(() => {
539535
fixture.destroy();
540-
flush();
541536

542537
const multiFixture = TestBed.createComponent(MultiSelect);
543538

@@ -556,7 +551,6 @@ describe('MatSelect', () => {
556551
it('should toggle the next option when pressing shift + DOWN_ARROW on a multi-select',
557552
fakeAsync(() => {
558553
fixture.destroy();
559-
flush();
560554

561555
const multiFixture = TestBed.createComponent(MultiSelect);
562556
const event = createKeyboardEvent('keydown', DOWN_ARROW);
@@ -585,7 +579,6 @@ describe('MatSelect', () => {
585579
it('should toggle the previous option when pressing shift + UP_ARROW on a multi-select',
586580
fakeAsync(() => {
587581
fixture.destroy();
588-
flush()
589582

590583
const multiFixture = TestBed.createComponent(MultiSelect);
591584
const event = createKeyboardEvent('keydown', UP_ARROW);
@@ -653,7 +646,6 @@ describe('MatSelect', () => {
653646

654647
it('should set `aria-multiselectable` to true on multi-select instances', fakeAsync(() => {
655648
fixture.destroy();
656-
flush();
657649

658650
const multiFixture = TestBed.createComponent(MultiSelect);
659651

@@ -740,7 +732,6 @@ describe('MatSelect', () => {
740732
it('should restore focus to the trigger after selecting an option in multi-select mode',
741733
fakeAsync(() => {
742734
fixture.destroy();
743-
flush();
744735

745736
const multiFixture = TestBed.createComponent(MultiSelect);
746737
const instance = multiFixture.componentInstance;

src/lib/select/select.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
762762
this._changeDetectorRef.detectChanges();
763763
this._calculateOverlayOffsetX();
764764
this.panel.nativeElement.scrollTop = this._scrollTop;
765-
this._hideBackdrop();
766765
});
767766
}
768767

@@ -780,6 +779,8 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
780779
private _showBackdrop() {
781780
if (this.overlayDir.overlayRef.backdropElement) {
782781
this.overlayDir.overlayRef.backdropElement.style.display = 'block';
782+
} else {
783+
this.overlayDir.overlayRef.attachBackdrop();
783784
}
784785
}
785786

0 commit comments

Comments
 (0)