Reproduction
https://stackblitz.com/edit/components-issue-yh1yjm?file=src/app/example-component.ts
Steps to reproduce:
- Spawn a flexible position based overlay.
- Make overlay contents height larger than viewport height such that overflow occurs.
- Make viewport height a floating point number with decimal portion between .0 to .5.
- The overlay will now overflow out of the viewport bounds.
- Make the viewport height a floating point number between .5 to next whole number, or a whole number.
- The overlay will now correctly stay within the viewport bounds.
Notes:
If you just try slowly resizing the window height while the overlay is open, you will see it bounce in and out of the viewport as the window height cycles between bad and good numbers.
Problem is that viewport height is a rounded number, and overlay height is a floating point. Therefore when viewport rounds down, the following check fails.
|
if (overlay.height <= viewport.height) { |
To compare the two numbers, the rounding needs to be consistent.
Expected Behavior
Flexible dimension overlay should always remain within viewport bounds.
Actual Behavior
Flexible dimension overlay does not remain within viewport bounds when viewport height rounds down.
Environment
- Angular: 10.2.3
- CDK/Material: 10.2.7
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 10
Reproduction
https://stackblitz.com/edit/components-issue-yh1yjm?file=src/app/example-component.ts
Steps to reproduce:
Notes:
If you just try slowly resizing the window height while the overlay is open, you will see it bounce in and out of the viewport as the window height cycles between bad and good numbers.
Problem is that viewport height is a rounded number, and overlay height is a floating point. Therefore when viewport rounds down, the following check fails.
components/src/cdk/overlay/position/flexible-connected-position-strategy.ts
Line 632 in e436479
To compare the two numbers, the rounding needs to be consistent.
Expected Behavior
Flexible dimension overlay should always remain within viewport bounds.
Actual Behavior
Flexible dimension overlay does not remain within viewport bounds when viewport height rounds down.
Environment