feat: deprecated dropdown center placement
parent
b82dd34c72
commit
e565423c7e
|
@ -76,7 +76,7 @@ exports[`renders ./components/dropdown/demo/placement.vue correctly 1`] = `
|
||||||
</button>
|
</button>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
|
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
|
||||||
<!----><span>bottomCenter</span>
|
<!----><span>bottom</span>
|
||||||
</button>
|
</button>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
|
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
|
||||||
|
@ -87,7 +87,7 @@ exports[`renders ./components/dropdown/demo/placement.vue correctly 1`] = `
|
||||||
</button>
|
</button>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
|
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
|
||||||
<!----><span>topCenter</span>
|
<!----><span>top</span>
|
||||||
</button>
|
</button>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
|
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
|
||||||
|
|
|
@ -53,10 +53,10 @@ export default defineComponent({
|
||||||
return {
|
return {
|
||||||
placements: [
|
placements: [
|
||||||
'bottomLeft',
|
'bottomLeft',
|
||||||
'bottomCenter',
|
'bottom',
|
||||||
'bottomRight',
|
'bottomRight',
|
||||||
'topLeft',
|
'topLeft',
|
||||||
'topCenter',
|
'top',
|
||||||
'topRight',
|
'topRight',
|
||||||
] as DropdownProps['placement'][],
|
] as DropdownProps['placement'][],
|
||||||
};
|
};
|
||||||
|
|
|
@ -83,10 +83,21 @@ const Dropdown = defineComponent({
|
||||||
};
|
};
|
||||||
|
|
||||||
const placement = computed(() => {
|
const placement = computed(() => {
|
||||||
if (props.placement !== undefined) {
|
const placement = props.placement;
|
||||||
return props.placement;
|
if (!placement) {
|
||||||
|
return direction.value === 'rtl' ? 'bottomRight' : 'bottomLeft';
|
||||||
}
|
}
|
||||||
return direction.value === 'rtl' ? 'bottomRight' : 'bottomLeft';
|
|
||||||
|
if (placement.includes('Center')) {
|
||||||
|
const newPlacement = placement.slice(0, placement.indexOf('Center'));
|
||||||
|
devWarning(
|
||||||
|
!placement.includes('Center'),
|
||||||
|
'Dropdown',
|
||||||
|
`You are using '${placement}' placement in Dropdown, which is deprecated. Try to use '${newPlacement}' instead.`,
|
||||||
|
);
|
||||||
|
return newPlacement;
|
||||||
|
}
|
||||||
|
return placement;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleVisibleChange = (val: boolean) => {
|
const handleVisibleChange = (val: boolean) => {
|
||||||
|
|
|
@ -39,7 +39,16 @@ const dropdownProps = () => ({
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
transitionName: PropTypes.string,
|
transitionName: PropTypes.string,
|
||||||
placement: PropTypes.oneOf(
|
placement: PropTypes.oneOf(
|
||||||
tuple('topLeft', 'topCenter', 'topRight', 'bottomLeft', 'bottomCenter', 'bottomRight'),
|
tuple(
|
||||||
|
'topLeft',
|
||||||
|
'topCenter',
|
||||||
|
'top',
|
||||||
|
'topRight',
|
||||||
|
'bottomLeft',
|
||||||
|
'bottomCenter',
|
||||||
|
'bottom',
|
||||||
|
'bottomRight',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
overlayClassName: PropTypes.string,
|
overlayClassName: PropTypes.string,
|
||||||
overlayStyle: PropTypes.style,
|
overlayStyle: PropTypes.style,
|
||||||
|
|
|
@ -41,6 +41,7 @@ export default function getPlacements(config: PlacementsConfig) {
|
||||||
horizontalArrowShift = 16,
|
horizontalArrowShift = 16,
|
||||||
verticalArrowShift = 8,
|
verticalArrowShift = 8,
|
||||||
autoAdjustOverflow,
|
autoAdjustOverflow,
|
||||||
|
arrowPointAtCenter,
|
||||||
} = config;
|
} = config;
|
||||||
const placementMap = {
|
const placementMap = {
|
||||||
left: {
|
left: {
|
||||||
|
@ -93,7 +94,7 @@ export default function getPlacements(config: PlacementsConfig) {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
Object.keys(placementMap).forEach(key => {
|
Object.keys(placementMap).forEach(key => {
|
||||||
placementMap[key] = config.arrowPointAtCenter
|
placementMap[key] = arrowPointAtCenter
|
||||||
? {
|
? {
|
||||||
...placementMap[key],
|
...placementMap[key],
|
||||||
overflow: getOverflowOptions(autoAdjustOverflow),
|
overflow: getOverflowOptions(autoAdjustOverflow),
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
</a-affix>
|
</a-affix>
|
||||||
</section>
|
</section>
|
||||||
<div class="fixed-widgets" :style="isZhCN ? { bottom: '175px' } : {}">
|
<div class="fixed-widgets" :style="isZhCN ? { bottom: '175px' } : {}">
|
||||||
<a-dropdown placement="topCenter">
|
<a-dropdown placement="top">
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
<a-menu
|
<a-menu
|
||||||
:selected-keys="[themeMode.theme.value]"
|
:selected-keys="[themeMode.theme.value]"
|
||||||
|
|
Loading…
Reference in New Issue