angular / angular/components

Setting maxHeight on overlay with flexibleConnectedTo strategy does not work, when viewport margin is also configured

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

Description

#### Reproduction

Steps to reproduce:
1. Visit the [stackblitz](https://stackblitz.com/edit/understanding-overlay-03-viewport-margin-bug)
2. Click the 2 buttons


#### Expected Behavior

That the max height of 300px is respected in both cases

#### Actual Behavior

Max height is only respected, if `withViewportMargin(10)` is not configured.

#### Environment

- Angular: 8.2.13
- CDK/Material: 8.2.3
- Browser(s): `Version 78.0.3904.70 (Official Build) (64-bit)`
- Operating System (e.g. Windows, macOS, Ubuntu): `macOS Mojave`

#### Gif

![bug-2](https://user-images.githubusercontent.com/9967422/68024963-e1d5c080-fcab-11e9-8f39-c4a25de26309.gif)

#### Relevant code

```typescript
const overlayRef = this.overlay.create({
hasBackdrop: true,
positionStrategy: this.overlay.position().flexibleConnectedTo(element)

// The max height is only respected, if the viewport margin is left out
.withViewportMargin(10) // <------

.withPositions([
{
originX: 'end',
originY: 'bottom',
overlayX: 'end',
overlayY: 'top',
},
]),
width: '200px',
maxHeight: '300px',
});
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz reproduction and the overlay.create example using flexibleConnectedTo, withViewportMargin(10), and maxHeight. Trace how the flexible connected positioning handles the viewport margin and verify the fix against both buttons, ensuring the 300px maximum height is respected in each case.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.