Skip to content

Commit

Permalink
fix(form): field required indication based on the label instead of th…
Browse files Browse the repository at this point in the history
…e group
  • Loading branch information
MartinWeb committed Sep 18, 2024
1 parent 40fc9a0 commit 0cb50f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 8 additions & 1 deletion packages/Form/core/src/Field.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getComponentClassName } from '@axa-fr/react-toolkit-core';
import React, { ComponentPropsWithoutRef, ReactNode } from 'react';
import classNames from 'classnames';
import FieldError from './FieldError';
import FieldForm from './FieldForm';
import MessageTypes from './MessageTypes';
Expand Down Expand Up @@ -53,7 +54,13 @@ const Field = ({
aria-label={ariaLabelContainer}>
<div className={classNameContainerLabel}>
<label
className="af-form__group-label"
className={classNames(
{
'af-form__group-label--required':
classModifier.includes('required'),
},
'af-form__group-label'
)}
htmlFor={isLabelContainerLinkedToInput ? id : null}>
{label}
</label>
Expand Down
4 changes: 1 addition & 3 deletions packages/Form/core/src/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
&__group-label {
font-weight: normal;
margin: 0;
}

&__group--required &__group-label {
&:after {
&--required::after {
content: ' *';
color: $color-red-error;
}
Expand Down

0 comments on commit 0cb50f3

Please sign in to comment.