Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SelectInput): overlay width not update on width change #3325

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
3 changes: 3 additions & 0 deletions src/popup/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ export default mixins(classPrefixMixins).extend({
}
});
}

this.$nextTick(() => {
this.popupMounted();
this.updateOverlayInnerStyle();
});
} else {
this.preventClosing(false);
Expand Down Expand Up @@ -442,6 +444,7 @@ export default mixins(classPrefixMixins).extend({
onResize={() => {
if (visible) {
this.updatePopper();
this.updateOverlayInnerStyle();
}
}}
parent={this}
Expand Down
3 changes: 3 additions & 0 deletions src/select-input/useOverlayInnerStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export default function useOverlayInnerStyle(
const matchWidthFunc = (triggerElement: HTMLElement, popupElement: HTMLElement) => {
// 避免因滚动条出现文本省略,预留宽度 8
const SCROLLBAR_WIDTH = popupElement.scrollHeight > popupElement.offsetHeight ? 8 : 0;
// 先重置掉设置才能获取到内部原始真实宽度
// eslint-disable-next-line no-param-reassign
popupElement.style.width = '';
const width = popupElement.offsetWidth + SCROLLBAR_WIDTH >= triggerElement.offsetWidth
? popupElement.offsetWidth
: triggerElement.offsetWidth;
Expand Down
Loading