Semantic-ui-react: Checkbox label not rendered if using a component

Created on 17 Jun 2018  路  1Comment  路  Source: Semantic-Org/Semantic-UI-React

Bug Report

Steps

// FormattedMessage is from react-intl and renders as <span>dummy</span>
<Checkbox label={<FormattedMessage defaultMessage="dummy" />} />

When used this way, the label DOM node will be completely replaced by the supplied component (in this case a span) and the checkbox will not be usable.

Expected Result

React:
<Checkbox label={<span>test</span>} />
DOM:

<div class="ui checkbox">
  <input type="checkbox" class="hidden" readonly="" tabindex="0" value="on">
  <label><span>test</span></label>
</div>

Actual Result

React:
<Checkbox label={<span>test</span>} />
DOM:

<div class="ui checkbox">
  <input type="checkbox" class="hidden" readonly="" tabindex="0" value="on">
  <span>test</span>
</div>

Version

0.81.1

Testcase

https://codesandbox.io/s/1336kzlyw3

invalid

Most helpful comment

Ir's an expected result, you need to use:

Checkbox label={{ children: <span>test</span>}} />
<div class="ui checkbox">
  <input type="checkbox" class="hidden" readonly="" tabindex="0" />
  <label><span>test</span></label>
</div>

>All comments

Ir's an expected result, you need to use:

Checkbox label={{ children: <span>test</span>}} />
<div class="ui checkbox">
  <input type="checkbox" class="hidden" readonly="" tabindex="0" />
  <label><span>test</span></label>
</div>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dilizarov picture dilizarov  路  3Comments

mattmacpherson picture mattmacpherson  路  3Comments

Ctesias picture Ctesias  路  3Comments

SajagTiwari picture SajagTiwari  路  3Comments

AlvMF1 picture AlvMF1  路  3Comments