-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(overlay): disable pointer events if overlay is detached #2747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,10 +35,15 @@ export class OverlayRef implements PortalHost { | |
| } | ||
|
|
||
| let attachResult = this._portalHost.attach(portal); | ||
|
|
||
| // Update the pane element with the given state configuration. | ||
| this.updateSize(); | ||
| this.updateDirection(); | ||
| this.updatePosition(); | ||
|
|
||
| // Enable pointer events for the overlay pane element. | ||
| this._togglePointerEvents(true); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't these enabled by default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah they are enabled by default. But developers can always call |
||
|
|
||
| return attachResult; | ||
| } | ||
|
|
||
|
|
@@ -48,6 +53,12 @@ export class OverlayRef implements PortalHost { | |
| */ | ||
| detach(): Promise<any> { | ||
| this._detachBackdrop(); | ||
|
|
||
| // When the overlay is detached, the pane element should disable pointer events. | ||
| // This is necessary because otherwise the pane element will cover the page and disable | ||
| // pointer events therefore. Depends on the position strategy and the applied pane boundaries. | ||
| this._togglePointerEvents(false); | ||
|
|
||
| return this._portalHost.detach(); | ||
| } | ||
|
|
||
|
|
@@ -115,6 +126,11 @@ export class OverlayRef implements PortalHost { | |
| } | ||
| } | ||
|
|
||
| /** Toggles the pointer events for the overlay pane element. */ | ||
| private _togglePointerEvents(enablePointer: boolean) { | ||
| this._pane.style.pointerEvents = enablePointer ? null : 'none'; | ||
| } | ||
|
|
||
| /** Attaches a backdrop for this overlay. */ | ||
| private _attachBackdrop() { | ||
| this._backdropElement = document.createElement('div'); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be better to use
querySelectorhere, otherwise the test will break if we changed the DOM order.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as there's a unit test for the behavior it should be okay
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it shouldn't be necessary. Nevertheless I just changed it (Testing the dismiss review button)