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: (FormItem) help icon click stopPropagation #6549

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/form/form-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const FormItemLayout: FC<FormItemLayoutProps> = props => {
<span
className={`${classPrefix}-label-help`}
onClick={e => {
e.stopPropagation()
e.preventDefault()
}}
>
Expand Down
24 changes: 24 additions & 0 deletions src/components/form/tests/form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,28 @@
expect(renderTimes).toEqual(1)
})
})

test('click help not propagate', () => {
jest.useFakeTimers()
const onClick = jest.fn()

const { container } = render(
<div onClick={onClick}>
<Form>
<Form.Item name='name' label='name' help='hello world'>
<Input />
</Form.Item>
</Form>
</div>
)

fireEvent.click(container.querySelector('.adm-form-item-label-help')!)

Check warning on line 348 in src/components/form/tests/form.test.tsx

View workflow job for this annotation

GitHub Actions / check

Forbidden non-null assertion
expect(onClick).not.toHaveBeenCalled()

// Click input
fireEvent.click(container.querySelector('input')!)

Check warning on line 352 in src/components/form/tests/form.test.tsx

View workflow job for this annotation

GitHub Actions / check

Forbidden non-null assertion
expect(onClick).toHaveBeenCalled()

jest.useRealTimers()
})
})
Loading