codegouvfr / react-dsfr

🇫🇷 The Frech Government Design system React toolkit
https://react-dsfr.codegouv.studio
MIT License
403 stars 49 forks source link

fix: do not display empty `<label></label>` #275

Closed ddecrulle closed 1 month ago

ddecrulle commented 1 month ago

The props label and hintText are ReactNodes. They can therefore be null, undefined, or an empty string (""). In these cases, the rendered HTML will be an empty <label> tag. This PR fixes this issue.

There is a side effect: if the provided label or hintText is the boolean false, it will not be displayed. I don't think this is problematic; it will simply require casting the boolean to a string.

revolunet commented 1 month ago

Thanks !

garronej commented 1 month ago

Thanks!

ddecrulle commented 1 week ago

The DSFR components Checkbox, Radio, and Switch need the <label> to be properly displayed. I have reverted these components.