Skip to content

Commit d5270e9

Browse files
committed
fix: cascader auto adjust overflow, close #5482
1 parent 6d2bcf0 commit d5270e9

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

components/vc-select/SelectTrigger.tsx

+5-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { computed, ref, defineComponent } from 'vue';
66
import type { VueNode } from '../_util/type';
77
import type { DropdownRender, Placement, RenderDOMFunc } from './BaseSelect';
88

9-
const getBuiltInPlacements = (adjustX: number) => {
9+
const getBuiltInPlacements = (dropdownMatchSelectWidth: number | boolean) => {
10+
// Enable horizontal overflow auto-adjustment when a custom dropdown width is provided
11+
const adjustX = dropdownMatchSelectWidth === true ? 0 : 1;
1012
return {
1113
bottomLeft: {
1214
points: ['tl', 'bl'],
@@ -43,14 +45,6 @@ const getBuiltInPlacements = (adjustX: number) => {
4345
};
4446
};
4547

46-
const getAdjustX = (
47-
adjustXDependencies: Pick<SelectTriggerProps, 'autoAdjustOverflow' | 'dropdownMatchSelectWidth'>,
48-
) => {
49-
const { autoAdjustOverflow, dropdownMatchSelectWidth } = adjustXDependencies;
50-
if (!!autoAdjustOverflow) return 1;
51-
// Enable horizontal overflow auto-adjustment when a custom dropdown width is provided
52-
return typeof dropdownMatchSelectWidth !== 'number' ? 0 : 1;
53-
};
5448
export interface RefTriggerProps {
5549
getPopupElement: () => HTMLDivElement;
5650
}
@@ -72,7 +66,6 @@ export interface SelectTriggerProps {
7266
getPopupContainer?: RenderDOMFunc;
7367
dropdownAlign: object;
7468
empty: boolean;
75-
autoAdjustOverflow?: boolean;
7669
getTriggerDOMNode: () => any;
7770
onPopupVisibleChange?: (visible: boolean) => void;
7871

@@ -90,7 +83,6 @@ const SelectTrigger = defineComponent<SelectTriggerProps, { popupRef: any }>({
9083
dropdownStyle: PropTypes.object,
9184
placement: String,
9285
empty: { type: Boolean, default: undefined },
93-
autoAdjustOverflow: { type: Boolean, default: undefined },
9486
prefixCls: String,
9587
popupClassName: String,
9688
animation: String,
@@ -107,13 +99,8 @@ const SelectTrigger = defineComponent<SelectTriggerProps, { popupRef: any }>({
10799
} as any,
108100
setup(props, { slots, attrs, expose }) {
109101
const builtInPlacements = computed(() => {
110-
const { autoAdjustOverflow, dropdownMatchSelectWidth } = props;
111-
return getBuiltInPlacements(
112-
getAdjustX({
113-
autoAdjustOverflow,
114-
dropdownMatchSelectWidth,
115-
}),
116-
);
102+
const { dropdownMatchSelectWidth } = props;
103+
return getBuiltInPlacements(dropdownMatchSelectWidth);
117104
});
118105
const popupRef = ref();
119106
expose({

0 commit comments

Comments
 (0)