Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/popup/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ export default defineComponent({
}}
onResize={() => {
if (visible.value) {
updateOverlayInnerStyle();
updatePopper();
}
}}
Expand Down
15 changes: 4 additions & 11 deletions packages/components/select-input/hooks/useOverlayInnerStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,14 @@ export type overlayInnerStyleProps = Pick<

// 单位:px
const MAX_POPUP_WIDTH = 1000;
// 避免因滚动条出现文本省略,预留宽度 8
const RESERVE_WIDTH = 0;

export function useOverlayInnerStyle(props: overlayInnerStyleProps) {
const { popupProps, autoWidth } = toRefs(props);
const innerPopupVisible = ref(false);
const disable = useDisabled();
const isReadonly = useReadonly();

const matchWidthFunc = (triggerElement: HTMLElement, popupElement: HTMLElement) => {
const SCROLLBAR_WIDTH = popupElement.scrollHeight > popupElement.offsetHeight ? RESERVE_WIDTH : 0;
const width =
popupElement.offsetWidth + SCROLLBAR_WIDTH >= triggerElement.offsetWidth
? popupElement.offsetWidth
: triggerElement.offsetWidth;
const matchWidthFunc = (triggerElement: HTMLElement) => {
let otherOverlayInnerStyle: CSSProperties = {};
if (
popupProps.value &&
Expand All @@ -36,7 +29,7 @@ export function useOverlayInnerStyle(props: overlayInnerStyleProps) {
otherOverlayInnerStyle = popupProps.value.overlayInnerStyle;
}
return {
width: `${Math.min(width, MAX_POPUP_WIDTH)}px`,
width: `${Math.min(triggerElement.offsetWidth, MAX_POPUP_WIDTH)}px`,
...otherOverlayInnerStyle,
};
};
Expand All @@ -52,9 +45,9 @@ export function useOverlayInnerStyle(props: overlayInnerStyleProps) {
}
};

const getAutoWidthPopupStyleWidth = (triggerElement: HTMLElement, popupElement: HTMLElement) => {
const getAutoWidthPopupStyleWidth = (triggerElement: HTMLElement) => {
return {
width: `${Math.max(triggerElement.offsetWidth, popupElement.offsetWidth)}px`,
width: `${Math.min(triggerElement.offsetWidth, MAX_POPUP_WIDTH)}px`,
...popupProps.value?.overlayInnerStyle,
};
};
Expand Down
Loading