Skip to content

Commit fb50b3d

Browse files
committed
Switcht to disable pointerEvents
1 parent be56a67 commit fb50b3d

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/lib/core/overlay/overlay-directives.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ describe('Overlay directives', () => {
3939
fixture.detectChanges();
4040

4141
expect(overlayContainerElement.textContent).toContain('Menu content');
42-
expect(getPaneElement().style.visibility)
43-
.toBeFalsy('Expected the overlay pane to be visible when attached.');
42+
expect(getPaneElement().style.pointerEvents)
43+
.toBeFalsy('Expected the overlay pane to enable pointerEvents when attached.');
4444

4545
fixture.componentInstance.isOpen = false;
4646
fixture.detectChanges();
4747

4848
expect(overlayContainerElement.textContent).toBe('');
49-
expect(getPaneElement().style.visibility)
50-
.toBe('hidden', 'Expected the overlay pane to be hidden when detached.');
49+
expect(getPaneElement().style.pointerEvents)
50+
.toBe('none', 'Expected the overlay pane to disable pointerEvents when detached.');
5151
});
5252

5353
it('should destroy the overlay when the directive is destroyed', () => {

src/lib/core/overlay/overlay-ref.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export class OverlayRef implements PortalHost {
4141
this.updateDirection();
4242
this.updatePosition();
4343

44-
// Make the pane element visible when overlay is attached.
45-
this._toggleVisibility(true);
44+
// Enable pointer events for the overlay pane element.
45+
this._togglePointerEvents(true);
4646

4747
return attachResult;
4848
}
@@ -54,10 +54,10 @@ export class OverlayRef implements PortalHost {
5454
detach(): Promise<any> {
5555
this._detachBackdrop();
5656

57-
// When the overlay is detached, the pane element should be invisible.
58-
// This is necessary because otherwise the pane element can cover the page and disable
59-
// pointer events. Depends on the position strategy and the applied pane boundaries.
60-
this._toggleVisibility(false);
57+
// When the overlay is detached, the pane element should disable pointer events.
58+
// This is necessary because otherwise the pane element will cover the page and disable
59+
// pointer events therefore. Depends on the position strategy and the applied pane boundaries.
60+
this._togglePointerEvents(false);
6161

6262
return this._portalHost.detach();
6363
}
@@ -126,9 +126,9 @@ export class OverlayRef implements PortalHost {
126126
}
127127
}
128128

129-
/** Toggles the visibility of the overlay pane element. */
130-
private _toggleVisibility(isVisible: boolean) {
131-
this._pane.style.visibility = isVisible ? null : 'hidden';
129+
/** Toggles the pointer events for the overlay pane element. */
130+
private _togglePointerEvents(enablePointer: boolean) {
131+
this._pane.style.pointerEvents = enablePointer ? null : 'none';
132132
}
133133

134134
/** Attaches a backdrop for this overlay. */

src/lib/core/overlay/overlay.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ describe('Overlay', () => {
6262
expect(overlayContainerElement.textContent).toBe('');
6363
});
6464

65-
it('should hide the pane element if the overlay is detached', () => {
65+
it('should disable pointer events of the pane element if detached', () => {
6666
let overlayRef = overlay.create();
6767
let paneElement = overlayRef.overlayElement;
6868

6969
overlayRef.attach(componentPortal);
7070

7171
expect(paneElement.childNodes.length).not.toBe(0);
72-
expect(paneElement.style.visibility)
73-
.toBeFalsy('Expected the overlay pane to be visible when attached.');
72+
expect(paneElement.style.pointerEvents)
73+
.toBeFalsy('Expected the overlay pane to enable pointerEvents when attached.');
7474

7575
overlayRef.detach();
7676

7777
expect(paneElement.childNodes.length).toBe(0);
78-
expect(paneElement.style.visibility)
79-
.toBe('hidden', 'Expected the overlay pane to be hidden when detached.');
78+
expect(paneElement.style.pointerEvents)
79+
.toBe('none', 'Expected the overlay pane to disable pointerEvents when detached.');
8080
});
8181

8282
it('should open multiple overlays', () => {

0 commit comments

Comments
 (0)