Skip to content

Commit e565423

Browse files
committed
feat: deprecated dropdown center placement
1 parent b82dd34 commit e565423

File tree

6 files changed

+31
-10
lines changed

6 files changed

+31
-10
lines changed

components/dropdown/__tests__/__snapshots__/demo.test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ exports[`renders ./components/dropdown/demo/placement.vue correctly 1`] = `
7676
</button>
7777
<!--v-if-->
7878
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
79-
<!----><span>bottomCenter</span>
79+
<!----><span>bottom</span>
8080
</button>
8181
<!--v-if-->
8282
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
@@ -87,7 +87,7 @@ exports[`renders ./components/dropdown/demo/placement.vue correctly 1`] = `
8787
</button>
8888
<!--v-if-->
8989
<!----><button class="ant-btn ant-dropdown-trigger" type="button">
90-
<!----><span>topCenter</span>
90+
<!----><span>top</span>
9191
</button>
9292
<!--v-if-->
9393
<!----><button class="ant-btn ant-dropdown-trigger" type="button">

components/dropdown/demo/placement.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ export default defineComponent({
5353
return {
5454
placements: [
5555
'bottomLeft',
56-
'bottomCenter',
56+
'bottom',
5757
'bottomRight',
5858
'topLeft',
59-
'topCenter',
59+
'top',
6060
'topRight',
6161
] as DropdownProps['placement'][],
6262
};

components/dropdown/dropdown.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,21 @@ const Dropdown = defineComponent({
8383
};
8484

8585
const placement = computed(() => {
86-
if (props.placement !== undefined) {
87-
return props.placement;
86+
const placement = props.placement;
87+
if (!placement) {
88+
return direction.value === 'rtl' ? 'bottomRight' : 'bottomLeft';
8889
}
89-
return direction.value === 'rtl' ? 'bottomRight' : 'bottomLeft';
90+
91+
if (placement.includes('Center')) {
92+
const newPlacement = placement.slice(0, placement.indexOf('Center'));
93+
devWarning(
94+
!placement.includes('Center'),
95+
'Dropdown',
96+
`You are using '${placement}' placement in Dropdown, which is deprecated. Try to use '${newPlacement}' instead.`,
97+
);
98+
return newPlacement;
99+
}
100+
return placement;
90101
});
91102

92103
const handleVisibleChange = (val: boolean) => {

components/dropdown/props.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,16 @@ const dropdownProps = () => ({
3939
prefixCls: PropTypes.string,
4040
transitionName: PropTypes.string,
4141
placement: PropTypes.oneOf(
42-
tuple('topLeft', 'topCenter', 'topRight', 'bottomLeft', 'bottomCenter', 'bottomRight'),
42+
tuple(
43+
'topLeft',
44+
'topCenter',
45+
'top',
46+
'topRight',
47+
'bottomLeft',
48+
'bottomCenter',
49+
'bottom',
50+
'bottomRight',
51+
),
4352
),
4453
overlayClassName: PropTypes.string,
4554
overlayStyle: PropTypes.style,

components/tooltip/placements.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default function getPlacements(config: PlacementsConfig) {
4141
horizontalArrowShift = 16,
4242
verticalArrowShift = 8,
4343
autoAdjustOverflow,
44+
arrowPointAtCenter,
4445
} = config;
4546
const placementMap = {
4647
left: {
@@ -93,7 +94,7 @@ export default function getPlacements(config: PlacementsConfig) {
9394
},
9495
};
9596
Object.keys(placementMap).forEach(key => {
96-
placementMap[key] = config.arrowPointAtCenter
97+
placementMap[key] = arrowPointAtCenter
9798
? {
9899
...placementMap[key],
99100
overflow: getOverflowOptions(autoAdjustOverflow),

site/src/layouts/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</a-affix>
5555
</section>
5656
<div class="fixed-widgets" :style="isZhCN ? { bottom: '175px' } : {}">
57-
<a-dropdown placement="topCenter">
57+
<a-dropdown placement="top">
5858
<template #overlay>
5959
<a-menu
6060
:selected-keys="[themeMode.theme.value]"

0 commit comments

Comments
 (0)