diff --git a/src/modules/Checkbox/Checkbox.js b/src/modules/Checkbox/Checkbox.js index 16d7362e5d..a2dcff30ef 100644 --- a/src/modules/Checkbox/Checkbox.js +++ b/src/modules/Checkbox/Checkbox.js @@ -148,8 +148,9 @@ export default class Checkbox extends Component { const { id } = this.props const { checked, indeterminate } = this.state + const isLabelClick = _.invoke(this.labelRef.current, 'contains', e.target) + const hasId = !_.isNil(id) - const isLabelClick = e.target === this.labelRef.current const isLabelClickAndForwardedToInput = isLabelClick && hasId // https://github.com/Semantic-Org/Semantic-UI-React/pull/3351 diff --git a/test/specs/modules/Checkbox/Checkbox-test.js b/test/specs/modules/Checkbox/Checkbox-test.js index 15940c5e77..4eb348ec36 100644 --- a/test/specs/modules/Checkbox/Checkbox-test.js +++ b/test/specs/modules/Checkbox/Checkbox-test.js @@ -249,6 +249,16 @@ describe('Checkbox', () => { wrapper.find('label').simulate('click') onChange.should.have.not.been.called() }) + + it('is called when click is done on nested element', () => { + const onChange = sandbox.spy() + wrapperMount(Foo }} onChange={onChange} />) + + wrapper.find('span').simulate('mouseup') + wrapper.find('span').simulate('click') + + onChange.should.have.been.calledOnce() + }) }) describe('onClick', () => {