Skip to content

Commit

Permalink
fix: Form label tooltip icon trigger Switch (ant-design#46155)
Browse files Browse the repository at this point in the history
* fix: Form label tooltip icon trigger Switch

close ant-design#46154

* chore: fix test case
  • Loading branch information
afc163 authored Nov 30, 2023
1 parent 005fc97 commit 7488c58
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/form/FormItemLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,16 @@ const FormItemLabel: React.FC<FormItemLabelProps & { required?: boolean; prefixC
const { icon = <QuestionCircleOutlined />, ...restTooltipProps } = tooltipProps;
const tooltipNode: React.ReactNode = (
<Tooltip {...restTooltipProps}>
{React.cloneElement(icon, { className: `${prefixCls}-item-tooltip`, title: '' })}
{React.cloneElement(icon, {
className: `${prefixCls}-item-tooltip`,
title: '',
onClick: (e: React.MouseEvent) => {
// Prevent label behavior in tooltip icon
// https://github.com/ant-design/ant-design/issues/46154
e.preventDefault();
},
tabIndex: null,
})}
</Tooltip>
);

Expand Down
1 change: 1 addition & 0 deletions components/form/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,7 @@ describe('Form', () => {
);

fireEvent.mouseEnter(container.querySelector('.anticon-question-circle')!);
fireEvent.click(container.querySelector('.anticon-question-circle')!);
await waitFakeTimer();

expect(container.querySelector('.ant-tooltip-inner')).toHaveTextContent('Bamboo');
Expand Down

0 comments on commit 7488c58

Please sign in to comment.