Skip to content
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

bug(cdk/overlay): BlockScrollStrategy is not working properly when overlay is called inside OnInit #28922

Closed
thekhegay opened this issue Apr 21, 2024 · 1 comment
Labels
needs triage This issue needs to be triaged by the team

Comments

@thekhegay
Copy link

thekhegay commented Apr 21, 2024

Description

I didn't find any description in the documentation, but when Overlay creation called in OnInit, BlockScrollStrategy is not blocking scroll.

I noticed another behavior:

  • height: 101vh applied as app-root styles, block is working fine (stackblitz)
  • height: 101vh is applied as .root class with @HostBinding call - block is not working (stackblitz)

I think related: #19020, #22217

Reproduction

Everything works fine when called inside AfterViewInit: https://stackblitz.com/edit/stackblitz-starters-sp8ikj?file=src%2Fmain.ts

Environment

  • Angular: 17.3.5
  • CDK/Material: 17.3.5
  • Browser(s): any
  • Operating System (e.g. Windows, macOS, Ubuntu): any
@thekhegay thekhegay added the needs triage This issue needs to be triaged by the team label Apr 21, 2024
@crisbeto
Copy link
Member

crisbeto commented May 8, 2024

The strategy needs to measure the sizes of elements in order to block scrolling. ngOnInit is likely too early for that to happen reliably. You can try either moving it to a later hook or wrapping it in a requestAnimationFrame.

@crisbeto crisbeto closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

2 participants