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: Form label tooltip icon trigger Switch #46155

Merged
merged 2 commits into from Nov 30, 2023
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
11 changes: 10 additions & 1 deletion components/form/FormItemLabel.tsx
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();
MadCcc marked this conversation as resolved.
Show resolved Hide resolved
},
tabIndex: null,
})}
</Tooltip>
);

Expand Down
1 change: 1 addition & 0 deletions components/form/__tests__/index.test.tsx
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