-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(inlinecheckbox): do not propagate click event from label (#10151)
* fix(inlinecheckbox): do not propagate click event from label * test(inlinecheckbox): update snaps
- Loading branch information
1 parent
d724a26
commit 12ac684
Showing
6 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/react/src/components/InlineCheckbox/InlineCheckbox-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import InlineCheckbox from '../InlineCheckbox'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
describe('InlineCheckbox', () => { | ||
it('should render', () => { | ||
render(<InlineCheckbox />); | ||
expect(screen.getByRole('checkbox')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should only propagate click events from the input', () => { | ||
const onClick = jest.fn(); | ||
render( | ||
/* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */ | ||
<div onClick={onClick}> | ||
<InlineCheckbox /> | ||
</div> | ||
); | ||
userEvent.click(screen.getByRole('checkbox')); | ||
expect(onClick).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters