Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0cb50f3

Browse files
committedSep 18, 2024·
fix(form): field required indication based on the label instead of the group
1 parent 40fc9a0 commit 0cb50f3

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed
 

‎packages/Form/core/src/Field.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getComponentClassName } from '@axa-fr/react-toolkit-core';
22
import React, { ComponentPropsWithoutRef, ReactNode } from 'react';
3+
import classNames from 'classnames';
34
import FieldError from './FieldError';
45
import FieldForm from './FieldForm';
56
import MessageTypes from './MessageTypes';
@@ -53,7 +54,13 @@ const Field = ({
5354
aria-label={ariaLabelContainer}>
5455
<div className={classNameContainerLabel}>
5556
<label
56-
className="af-form__group-label"
57+
className={classNames(
58+
{
59+
'af-form__group-label--required':
60+
classModifier.includes('required'),
61+
},
62+
'af-form__group-label'
63+
)}
5764
htmlFor={isLabelContainerLinkedToInput ? id : null}>
5865
{label}
5966
</label>

‎packages/Form/core/src/form.scss

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
&__group-label {
1919
font-weight: normal;
2020
margin: 0;
21-
}
2221

23-
&__group--required &__group-label {
24-
&:after {
22+
&--required::after {
2523
content: ' *';
2624
color: $color-red-error;
2725
}

0 commit comments

Comments
 (0)
Please sign in to comment.