From d5270e9a9df42143fd475282becce5b990919f46 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Tue, 12 Apr 2022 14:24:27 +0800 Subject: [PATCH] fix: cascader auto adjust overflow, close #5482 --- components/vc-select/SelectTrigger.tsx | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/components/vc-select/SelectTrigger.tsx b/components/vc-select/SelectTrigger.tsx index 8e9855bf5..64adb6d26 100644 --- a/components/vc-select/SelectTrigger.tsx +++ b/components/vc-select/SelectTrigger.tsx @@ -6,7 +6,9 @@ import { computed, ref, defineComponent } from 'vue'; import type { VueNode } from '../_util/type'; import type { DropdownRender, Placement, RenderDOMFunc } from './BaseSelect'; -const getBuiltInPlacements = (adjustX: number) => { +const getBuiltInPlacements = (dropdownMatchSelectWidth: number | boolean) => { + // Enable horizontal overflow auto-adjustment when a custom dropdown width is provided + const adjustX = dropdownMatchSelectWidth === true ? 0 : 1; return { bottomLeft: { points: ['tl', 'bl'], @@ -43,14 +45,6 @@ const getBuiltInPlacements = (adjustX: number) => { }; }; -const getAdjustX = ( - adjustXDependencies: Pick, -) => { - const { autoAdjustOverflow, dropdownMatchSelectWidth } = adjustXDependencies; - if (!!autoAdjustOverflow) return 1; - // Enable horizontal overflow auto-adjustment when a custom dropdown width is provided - return typeof dropdownMatchSelectWidth !== 'number' ? 0 : 1; -}; export interface RefTriggerProps { getPopupElement: () => HTMLDivElement; } @@ -72,7 +66,6 @@ export interface SelectTriggerProps { getPopupContainer?: RenderDOMFunc; dropdownAlign: object; empty: boolean; - autoAdjustOverflow?: boolean; getTriggerDOMNode: () => any; onPopupVisibleChange?: (visible: boolean) => void; @@ -90,7 +83,6 @@ const SelectTrigger = defineComponent({ dropdownStyle: PropTypes.object, placement: String, empty: { type: Boolean, default: undefined }, - autoAdjustOverflow: { type: Boolean, default: undefined }, prefixCls: String, popupClassName: String, animation: String, @@ -107,13 +99,8 @@ const SelectTrigger = defineComponent({ } as any, setup(props, { slots, attrs, expose }) { const builtInPlacements = computed(() => { - const { autoAdjustOverflow, dropdownMatchSelectWidth } = props; - return getBuiltInPlacements( - getAdjustX({ - autoAdjustOverflow, - dropdownMatchSelectWidth, - }), - ); + const { dropdownMatchSelectWidth } = props; + return getBuiltInPlacements(dropdownMatchSelectWidth); }); const popupRef = ref(); expose({