angular / angular/components

bug(Overlay): FlexibleConnectedPositionStrategy withViewportMargin not working

Đang mở
#24,259 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
area: cdk/overlay P3
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

When using overlay with `FlexibleConnectedPositionStrategy` and `withViewportMargin()`, overlay ignores provided margin value and still opens in first preffered position, when it should move to second one. Overlay cant be pushed and has no flexible dimmensions set.
![image](https://user-images.githubusercontent.com/17365268/150674093-04daf594-9194-47fb-ac60-98b1464d8502.png)

### Reproduction

https://stackblitz.com/edit/viewport-margin-bug?file=src%2Fapp%2Fapp.component.ts
(Red line shows 100px margin edge)

Steps to reproduce:
1. Create overlay with popup 100px x 100px
2. Locate its origin point 150px from top edge of viewport.
3. Add two positions to FlexibleConnectedPositionStrategy:
```
{
originX: 'end',
originY: 'top',
overlayX: 'start',
overlayY: 'bottom',
},
{
originX: 'end',
originY: 'bottom',
overlayX: 'start',
overlayY: 'top',
},
```
4. Use `withViewportMargin(100)`.
5. Use `withFlexibleDimensions(false)`
6. Use `withPush(false)`

### Expected Behavior

Since `withViewPortMargin(100)` was set, and overlay cannot be pushed or shrinked, then it should fallback to second preffered position in which popup opens downwards.
```
{
originX: 'end',
originY: 'bottom',
overlayX: 'start',
overlayY: 'top',
},
```

### Actual Behavior

Overlay still opens according to first position which is upward, ignoring viewport margin

### Environment

- Angular: 13.1.3
- CDK/Material: 13.1.3
- Browser(s): Chrome 97
- Operating System (e.g. Windows, macOS, Ubuntu): macOS

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với bản tái hiện StackBlitz được liên kết và kiểm tra FlexibleConnectedPositionStrategy, tập trung vào cách withViewportMargin tương tác với các kích thước linh hoạt bị vô hiệu hóa và hành vi push. Công việc được xem là hoàn tất khi overlay chuyển sang vị trí thứ hai nếu vị trí đầu tiên vi phạm margin viewport 100px, với coverage cho cấu hình đã được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.