fix: simplifies field error paths (#5504)

This commit is contained in:
Jarrod Flesch
2024-03-28 13:15:44 -04:00
committed by GitHub
parent 5873dfb731
commit 8636685252
17 changed files with 97 additions and 91 deletions

View File

@@ -13,6 +13,7 @@ import './index.scss'
const DefaultFieldLabel: React.FC<LabelProps> = (props) => {
const {
as: Element = 'label',
htmlFor: htmlForFromProps,
label: labelFromProps,
required = false,
@@ -27,10 +28,10 @@ const DefaultFieldLabel: React.FC<LabelProps> = (props) => {
if (labelFromProps) {
return (
<label className={`field-label ${unstyled ? 'unstyled' : ''}`} htmlFor={htmlFor}>
<Element className={`field-label ${unstyled ? 'unstyled' : ''}`} htmlFor={htmlFor}>
{getTranslation(labelFromProps, i18n)}
{required && !unstyled && <span className="required">*</span>}
</label>
</Element>
)
}