angular / angular/components

CDK overlay auto calculate width when using ConnectedPositionStrategy

未关闭
#10,393 13 条评论 22 个 reaction 已指派 0 人 在 GitHub 查看
area: cdk/overlay feature P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

#### Bug, feature request, or proposal:
Feature

#### What is the expected behavior?
That i can somehow configure the popup overlay to change it width to be the same as the parent, without having to add a bunch of custom styling to my popup component.
![good](https://user-images.githubusercontent.com/1499810/37336174-de6f20a8-26b0-11e8-8924-a2df159cceaf.png)

#### What is the current behavior?
![bad](https://user-images.githubusercontent.com/1499810/37336151-cfbf6fb8-26b0-11e8-9fc4-88e4d6adff71.png)

#### What is the use-case or motivation for changing an existing behavior?
I would have to do less custom styling to get a nice dropdown

#### Is there anything else we should know?
In the screenshots we have changed the width using css, however this is suboptimal to having a responsive design, where the input can change their width all the time.
To get around the problem we have to hard-code the width of both the input and the popups, so they look to fit together.

My best suggestion would be able to do something like this:

```typescript
this.overlay.position()
.connectedTo(target, {
originY: 'bottom',
originX: 'start'
}, {
overlayY: 'top',
overlayX: 'start'
})
.immitateWidth();
```

贡献指南

打开贡献指南

调研方向

从 CDK overlay ConnectedPositionStrategy API 开始,重现 issue 中描述的响应式宽度场景。完成标准是:连接的弹出窗口能够在父元素发生变化时匹配其宽度,而无需对弹出窗口组件进行自定义样式设置;报告中没有指定具体的源文件或测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。