angular / angular/components

Support intersection/clipping detection in overlay positioning

Open
#20,317 8 comments 0 reactions 0 assignees View on GitHub
area: cdk/overlay feature P4
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### What are you trying to do?

I am trying to set a position strategy that works when origin element is clipped. Is there any way to do this without writing a custom position strategy?

#### What troubleshooting steps have you tried?

I tried all the strategies available through CDK Api but without success.

#### Reproduction

https://stackblitz.com/edit/angular-rplbez

Basically, i have to 2 connected positions defined. First that will center the overlay below origin element and another one that will center the overlay above origin element. For example, if element is on the top of the page, overlay would go out of viewport and then second position will be used (below origin element). That works fine. But if origin element is clipped (as in stackblitz example) then overlay will be positioned using first position (above origin element).

Steps to reproduce:
1. Click on a blue square
2. Opened popover is over red header

#### Environment

- Angular: 10.0.9
- CDK/Material: 10.1.3
- Browser(s): Chrome 84.0
- Operating System (e.g. Windows, macOS, Ubuntu): MacOS 10.15.3

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz reproduction and inspect the CDK overlay positioning behavior for the two connected positions. Reproduce the clipped-origin case, then verify that intersection or clipping detection selects the alternate position while preserving the existing viewport fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.