components icon indicating copy to clipboard operation
components copied to clipboard

Full-screen overlay container doesn't work when fullscreen element is within an overlay

Open tmburnell opened this issue 7 years ago • 15 comments
trafficstars

Bug, feature request, or proposal:

I believe this might be a bug.
In this example I try to load a snackbar into a container using the viewContainerRef config. https://stackblitz.com/edit/angular-material-tooltip-in-container

What is the expected behavior?

The snackbar should align itself to the viewContainerRef that is provided.

What is the current behavior?

But the _createOverlay function does not look at this config and always creates the overlay using the GlobalPositionStrategy instead of ConnectedPositionStrategy.

There could be another root cause, and if there is please let me know.

What are the steps to reproduce?

I have provided a stackblitz above.

What is the use-case or motivation for changing an existing behavior?

There is a hand full of times i would like to load the snackbar in a container.
One in particular is the div has been maximized to full screen (so the window is not visible).
Therefore the snackbar is not visible.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

latest.

tmburnell avatar Apr 03 '18 15:04 tmburnell

This is working as intended. The ViewContainerRef determines the logical location of the snackbar, which determines change detection order and place in the injection tree, but it will always be rendered globally.

jelbourn avatar Apr 03 '18 22:04 jelbourn

@jelbourn so there is no way to render a snack bar in a container? So in my example where I can’t see window ... I just can’t use snackbar?

tmburnell avatar Apr 04 '18 02:04 tmburnell

The Material Design specification dictates the global nature of snackbars: https://material.io/guidelines/components/snackbars-toasts.html

jelbourn avatar Apr 04 '18 16:04 jelbourn

Here is an example of what i am talking about: https://angular-material-tooltip-in-container.stackblitz.io

tmburnell avatar Apr 04 '18 17:04 tmburnell

Oh, if you're just talking about full-screen support, you can use the FullScreenOverlayContainer

jelbourn avatar Apr 04 '18 17:04 jelbourn

So is there support for snackbar to utilize FullscreenOverlayContainer ? can you modify my stackblitz to demo? https://stackblitz.io/edit/angular-material-tooltip-in-container

tmburnell avatar Apr 04 '18 19:04 tmburnell

https://stackblitz.com/edit/angular-material-tooltip-in-container-fbuspp?file=app/app.module.ts

Providing it at the component level is too late, you just need to provide it higher up

jelbourn avatar Apr 04 '18 21:04 jelbourn

https://angular-material-tooltip-in-container.stackblitz.io/

I updated my example (to make it closer to my use case) and applied what was in your example.
Now loading of full screen causes an error:

ERROR DOMException: Failed to execute 'appendChild' on 'Node': The new child element contains the parent.
    at FullscreenOverlayContainer._adjustParentForFullscreenChange (https://angular-material-tooltip-in-container.stackblitz.io/turbo_modules/@angular/[email protected]/bundles/cdk-overlay.umd.js:3049:16)

I assume this is due to a dialog has already called Fullscreen.

tmburnell avatar Apr 05 '18 14:04 tmburnell

Looks like this doesn't work when trying to make the fullscreen element be within an overlay itself. I don't really see a good way to fix this, since the overlay container needs to be inside the fullscreen element for subsequent overlays to work.

jelbourn avatar Apr 05 '18 17:04 jelbourn

I have a solution that will work for now. https://angular-material-tooltip-in-container-2.stackblitz.io/

This uses custom snackbar and overlay's (thanks to this)

tmburnell avatar Apr 05 '18 18:04 tmburnell

I've added the FullscreenOverlayContainer to my @ngModule, and on desktop browsers, it works great! However, it does not work in fullscreen mode on Android - the menu is still shown behind the main content as it did before adding this provider. Is this a known issue and are there any workarounds to get this working on the android browser?

Ryan-Haines avatar Feb 05 '19 18:02 Ryan-Haines

I am also seeing the error with overlays: "There was a general error.Error: Failed to execute 'appendChild' on 'Node': The new child element contains the parent." from FullscreenOverlayContainer._adjustParentForFullscreenChange .

Do we have a solution to this?

tarangkhandelwal avatar Aug 14 '19 11:08 tarangkhandelwal

@tmburnell Thanks for reporting this issue.

I too facing this issue. We have map in modal component. Dropdown list is not visible when Full-Screen is enable on map.

Any workaround is highly appreciated.

image

Thanks.

manandkumaar avatar Mar 09 '21 13:03 manandkumaar

@manandkumaar this was the solution i used: https://github.com/angular/components/issues/10679#issuecomment-379029872

I might lock you into a version (where you would have to update it with angular) ... but this was the only answer i had.

tmburnell avatar Mar 10 '21 14:03 tmburnell

providers: [ { provide: OverlayContainer, useClass: FullscreenOverlayContainer }, ],

add this in your relevant module.ts file it will handle cases where your application is in full-screen mode. It ensures that overlays are appended correctly to the DOM when the application enters full-screen mode, so they remain visible.

Issue is closed 🙌

SushantMhashakhetri avatar Oct 14 '24 12:10 SushantMhashakhetri