Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix crash when mismatch placement #23756

Merged
merged 2 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ exports[`Tooltip should hide when mouse leave antd disabled component Switch 1`]
</button>
</span>
`;

exports[`Tooltip should works for mismatch placement 1`] = `
<span>
Hello world!
</span>
`;
15 changes: 15 additions & 0 deletions components/tooltip/__tests__/tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,19 @@ describe('Tooltip', () => {
await sleep(500);
expect(wrapper.instance().getPopupDomNode().className).toContain('placement-topRight');
});

it('should works for mismatch placement', async () => {
const wrapper = mount(
<Tooltip
title="xxxxx"
align={{
points: ['aa', 'bb'],
}}
>
<span>Hello world!</span>
</Tooltip>,
);

expect(wrapper.render()).toMatchSnapshot();
});
});
3 changes: 3 additions & 0 deletions components/tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ class Tooltip extends React.Component<TooltipProps, any> {
placements[key].points[0] === align.points[0] &&
placements[key].points[1] === align.points[1],
)[0];
if (!placement) {
return;
}
// 根据当前坐标设置动画点
const rect = domNode.getBoundingClientRect();
const transformOrigin = {
Expand Down