fix: Dropdown not auto adjust placement (#34390)

This commit is contained in:
二货机器人 2022-03-09 19:34:46 +08:00 committed by GitHub
parent b199d9d2fa
commit 235ab32f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -79,4 +79,24 @@ describe('Dropdown', () => {
expect.stringContaining("[antd: Dropdown] You are using 'topCenter'"),
);
});
// zombieJ: when replaced with react test lib, it may be mock fully content
it('dropdown should support auto adjust placement', () => {
const wrapper = mount(
<Dropdown overlay={<div>menu</div>} visible>
<button type="button">button</button>
</Dropdown>,
);
expect(wrapper.find('Trigger').prop('builtinPlacements')).toEqual(
expect.objectContaining({
bottomLeft: expect.objectContaining({
overflow: {
adjustX: 1,
adjustY: 1,
},
}),
}),
);
});
});

View File

@ -189,6 +189,7 @@ const Dropdown: DropdownInterface = props => {
const builtinPlacements = getPlacements({
arrowPointAtCenter: typeof arrow === 'object' && arrow.pointAtCenter,
autoAdjustOverflow: true,
});
return (