From 72952a8e1c6db12ad1a6136e47b739940c5eced0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hilal=20Ate=C5=9Falp?= Date: Thu, 26 Nov 2026 10:54:18 +0300 Subject: [PATCH 1/5] fix(Form): show the required mark on fields without a label --- src/lib/components/Checkbox/Checkbox.tsx | 2 +- .../__snapshots__/Checkbox.test.tsx.snap | 1 + .../Form/FormFields/FormField.module.scss | 57 ++++++++++++++++++- src/lib/components/PinCode/PinCode.tsx | 2 +- .../__snapshots__/PinCode.test.tsx.snap | 1 + src/lib/components/RadioGroup/RadioGroup.tsx | 2 +- .../__snapshots__/RadioGroup.test.tsx.snap | 1 + src/lib/components/Switch/Switch.tsx | 2 +- .../Switch/__snapshots__/Switch.test.tsx.snap | 1 + 9 files changed, 63 insertions(+), 6 deletions(-) diff --git a/src/lib/components/Checkbox/Checkbox.tsx b/src/lib/components/Checkbox/Checkbox.tsx index fe8cfa47..a9f1582c 100644 --- a/src/lib/components/Checkbox/Checkbox.tsx +++ b/src/lib/components/Checkbox/Checkbox.tsx @@ -40,7 +40,7 @@ const Checkbox = (p: PropsWithRefAndChildren) => ]); return ( -
+
:first-child:not(.groupItems), + &.horizontalGroup .groupItems > :last-child, + &.verticalGroup .groupItems > :first-child { + @content; + } +} .Root { display: flex; @@ -52,6 +61,42 @@ $sizes: ( } } +.required:not([data-has-label]) { + @include required-mark-anchor { + position: relative; + &[data-mtf-component="checkbox"], + &[data-mtf-component="switch"], + &[data-mtf-component="radio-group"], + &[data-mtf-component="pin-code"] { + align-self: flex-start; + } + &::after { + content: $required-mark; + position: absolute; + top: 0; + left: 100%; + padding-left: var(--base-sizing-2x); + color: var(--theme-color-text-base-caption); + } + } + + &.error { + @include required-mark-anchor { + &::after { + color: var(--theme-color-text-danger-default); + } + } + } + + &.disabled { + @include required-mark-anchor { + &::after { + color: var(--theme-color-text-base-disabled); + } + } + } +} + .helper { color: var(--theme-color-text-base-caption); white-space: pre-line; @@ -92,7 +137,7 @@ $sizes: ( .horizontalLabel { align-items: flex-start; &.required .label::before { - content: "*"; + content: $required-mark; } &.horizontalForm .inputContainer { flex: 1; @@ -102,7 +147,7 @@ $sizes: ( .verticalLabel { flex-direction: column; &.required .label::after { - content: "*"; + content: $required-mark; } } @@ -165,6 +210,14 @@ $sizes: ( @include font("base", $size, "500"); } + &.required:not([data-has-label]) { + @include required-mark-anchor { + &::after { + @include font("base", $size, "700"); + } + } + } + .helper { @include font("body", $helperSize); } diff --git a/src/lib/components/PinCode/PinCode.tsx b/src/lib/components/PinCode/PinCode.tsx index 8ab986cd..0d094566 100644 --- a/src/lib/components/PinCode/PinCode.tsx +++ b/src/lib/components/PinCode/PinCode.tsx @@ -107,7 +107,7 @@ const PinCodeComponent = (p: PropsWithRef) => { const classNames = sanitizeModuleRootClasses(styles, className, [size, circle && "circle"]); return ( -
+
{renderPinCodeItems()}
); diff --git a/src/lib/components/PinCode/__snapshots__/PinCode.test.tsx.snap b/src/lib/components/PinCode/__snapshots__/PinCode.test.tsx.snap index 55636de0..e502f495 100644 --- a/src/lib/components/PinCode/__snapshots__/PinCode.test.tsx.snap +++ b/src/lib/components/PinCode/__snapshots__/PinCode.test.tsx.snap @@ -4,6 +4,7 @@ exports[`PinCode should render with only required props, have default prop value
) => { const classNames = sanitizeModuleRootClasses(styles, className, [orientation, size, inFormField && "inFormField"]); return ( -
+
{children}
); diff --git a/src/lib/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap b/src/lib/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap index f4b0dc26..81fcfb7f 100644 --- a/src/lib/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +++ b/src/lib/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap @@ -4,6 +4,7 @@ exports[`RadioGroup should render with only required props, and have standard pr
) => { ]); return ( -
+
Date: Thu, 26 Nov 2026 11:20:08 +0300 Subject: [PATCH 2/5] fix(InputNumber): keep the required mark visible outside the input --- src/lib/components/InputNumber/InputNumber.module.scss | 4 +++- src/lib/components/Motif/InputText/InputText.module.scss | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/components/InputNumber/InputNumber.module.scss b/src/lib/components/InputNumber/InputNumber.module.scss index 5ef12926..ab7a0050 100644 --- a/src/lib/components/InputNumber/InputNumber.module.scss +++ b/src/lib/components/InputNumber/InputNumber.module.scss @@ -1,3 +1,5 @@ +@use "@styles" as *; + .Root { - overflow: hidden; + @include retain-scoped-class; } diff --git a/src/lib/components/Motif/InputText/InputText.module.scss b/src/lib/components/Motif/InputText/InputText.module.scss index c6436a4d..f75423f5 100644 --- a/src/lib/components/Motif/InputText/InputText.module.scss +++ b/src/lib/components/Motif/InputText/InputText.module.scss @@ -84,6 +84,7 @@ $sizes: (("xs", "8x", "4x", "18x", "28x"), ("sm", "12x", "6x", "20x", "32x"), (" .numberButtons { display: flex; align-self: stretch; + border-radius: inherit; button { all: unset; @include transition(background-color color); @@ -94,8 +95,8 @@ $sizes: (("xs", "8x", "4x", "18x", "28x"), ("sm", "12x", "6x", "20x", "32x"), (" border-left: var(--base-sizing-1x) solid var(--theme-color-border-light-disabled); &:last-child { - border-top-right-radius: var(--theme-sizing-radius-default); - border-bottom-right-radius: var(--theme-sizing-radius-default); + border-top-right-radius: inherit; + border-bottom-right-radius: inherit; } &:hover { color: var(--theme-color-text-base-title); From 9bc483c6d6e88c46255a528a1356f4d36f5b45f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hilal=20Ate=C5=9Falp?= Date: Mon, 30 Nov 2026 14:33:38 +0300 Subject: [PATCH 3/5] fix: reviews fixed --- .../Form/FormFields/FormField.module.scss | 43 ++++++------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/src/lib/components/Form/FormFields/FormField.module.scss b/src/lib/components/Form/FormFields/FormField.module.scss index bd7160b9..489426a5 100644 --- a/src/lib/components/Form/FormFields/FormField.module.scss +++ b/src/lib/components/Form/FormFields/FormField.module.scss @@ -12,39 +12,32 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6 } .Root { + --mtf-form-field-helper-color: var(--mtf-color-text-softer); display: flex; } -// The required mark, always after the label -.required { - --mtf-form-field-mark: "*"; +.error { + --mtf-form-field-helper-color: var(--mtf-color-danger-text); } -// The mark's color comes from the state and is read by both marks (on the label and on a field without a label), whose -// combined selectors would exceed the specificity limit (css.md section 4) -.error { - --mtf-form-field-mark-color: var(--mtf-color-danger-text); +.success { + --mtf-form-field-helper-color: var(--mtf-color-success-text); } .disabled { - --mtf-form-field-mark-color: var(--mtf-color-text-disabled); + --mtf-form-field-helper-color: var(--mtf-color-text-disabled); } .label { color: var(--mtf-color-text-strong); - &::after { - content: var(--mtf-form-field-mark, none); + .required &::after { + content: "*"; padding: 0 var(--mtf-sizing-space-2); - color: var(--mtf-form-field-mark-color, var(--mtf-color-text-softer)); + color: var(--mtf-form-field-helper-color); font-weight: var(--mtf-typography-weight-strongest); } - // After the base colors: same specificity, so error and disabled win by order - .error &::after { - color: var(--mtf-color-danger-text); - } - .disabled &, .disabled &::after { color: var(--mtf-color-text-disabled); @@ -61,32 +54,20 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6 align-self: flex-start; } &::after { - content: var(--mtf-form-field-mark, none); + content: "*"; position: absolute; top: 0; left: 100%; padding-left: var(--mtf-sizing-space-2); - color: var(--mtf-form-field-mark-color, var(--mtf-color-text-softer)); + color: var(--mtf-form-field-helper-color); } } } .helper { - color: var(--mtf-color-text-softer); + color: var(--mtf-form-field-helper-color); white-space: pre-line; @include transition(color); - - .error & { - color: var(--mtf-color-danger-text); - } - - .success & { - color: var(--mtf-color-success-text); - } - - .disabled & { - color: var(--mtf-color-text-disabled); - } } .inputContainer { From b9fb13a76b48800e27c0ef4985b85946b95fe01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hilal=20Ate=C5=9Falp?= Date: Mon, 30 Nov 2026 17:21:33 +0300 Subject: [PATCH 4/5] fix: render the required mark of a field without a label as an element --- src/lib/components/Checkbox/Checkbox.tsx | 2 +- .../__snapshots__/Checkbox.test.tsx.snap | 2 +- .../Form/FormFields/FormField.module.scss | 64 +++++++++---------- .../components/Form/FormFields/FormField.tsx | 10 ++- .../Form/FormFields/FormFieldGroup.tsx | 10 ++- src/lib/components/PinCode/PinCode.tsx | 2 +- .../__snapshots__/PinCode.test.tsx.snap | 2 +- src/lib/components/RadioGroup/RadioGroup.tsx | 2 +- .../__snapshots__/RadioGroup.test.tsx.snap | 2 +- src/lib/components/Switch/Switch.tsx | 2 +- .../Switch/__snapshots__/Switch.test.tsx.snap | 2 +- 11 files changed, 54 insertions(+), 46 deletions(-) diff --git a/src/lib/components/Checkbox/Checkbox.tsx b/src/lib/components/Checkbox/Checkbox.tsx index a9f1582c..12567133 100644 --- a/src/lib/components/Checkbox/Checkbox.tsx +++ b/src/lib/components/Checkbox/Checkbox.tsx @@ -40,7 +40,7 @@ const Checkbox = (p: PropsWithRefAndChildren) => ]); return ( -
+
:first-child:not(.groupItems), - &.horizontalGroup .groupItems > :last-child, - &.verticalGroup .groupItems > :first-child { - @content; - } -} - .Root { --mtf-form-field-helper-color: var(--mtf-color-text-softer); display: flex; @@ -28,6 +20,10 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6 --mtf-form-field-helper-color: var(--mtf-color-text-disabled); } +.mark { + color: var(--mtf-form-field-helper-color); +} + .label { color: var(--mtf-color-text-strong); @@ -44,26 +40,6 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6 } } -.required:not([data-has-label]) { - @include required-mark-anchor { - position: relative; - &[data-mtf-component="checkbox"], - &[data-mtf-component="switch"], - &[data-mtf-component="radio-group"], - &[data-mtf-component="pin-code"] { - align-self: flex-start; - } - &::after { - content: "*"; - position: absolute; - top: 0; - left: 100%; - padding-left: var(--mtf-sizing-space-2); - color: var(--mtf-form-field-helper-color); - } - } -} - .helper { color: var(--mtf-form-field-helper-color); white-space: pre-line; @@ -141,6 +117,30 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6 } } +// The control and the mark share the first line, the helper wraps to the next one +.withMark { + flex-flow: row wrap; + align-items: flex-start; + + // A zero basis keeps the mark on the control's line, however wide the control is + > :first-child { + flex: 1 1 0; + min-width: 0; + } + + // data-mtf-inline-control marks the controls as wide as their content (Checkbox, Switch, RadioGroup, PinCode), while + // the others fill the row. Such a control, or a group of only such controls, keeps its width, so the mark follows it + // instead of going to the row's end + > [data-mtf-inline-control], + > .groupItems:not(:has(> :not([data-mtf-inline-control]))) { + max-width: max-content; + } + + > .helper { + flex-basis: 100%; + } +} + @each $size, $helperStep, $gapVLabel, $gapHLabel, $marginTopHLabel, $gapHGroupItems in $sizes { .#{$size} { &.verticalLabel { @@ -170,12 +170,8 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6 @include typography("text-#{$size}", "strong"); } - &.required:not([data-has-label]) { - @include required-mark-anchor { - &::after { - @include typography("text-#{$size}", "strongest"); - } - } + .mark { + @include typography("text-#{$size}", "strongest"); } .helper { diff --git a/src/lib/components/Form/FormFields/FormField.tsx b/src/lib/components/Form/FormFields/FormField.tsx index 6779cd34..6ab78168 100644 --- a/src/lib/components/Form/FormFields/FormField.tsx +++ b/src/lib/components/Form/FormFields/FormField.tsx @@ -6,7 +6,7 @@ import { useForm } from "@/components/Form/context/FormContext"; import { FieldContext } from "@/components/Form/context/FieldContext"; import { PropsWithRef } from "../../../types"; import { FormFieldProps } from "@/components/Form/FormFields/types"; -import { sanitizeModuleRootClasses } from "../../../../utils/cssUtils"; +import { sanitizeModuleRootClasses, sanitizeModuleClasses } from "../../../../utils/cssUtils"; import usePropsWithThemeDefaults from "../../../motif/hooks/usePropsWithThemeDefaults"; const FormField = (props: PropsWithRef) => { @@ -23,6 +23,7 @@ const FormField = (props: PropsWithRef) => { const [error, setError] = useState(() => getInitialExternalError(name, disabled)); const isRequired = validations?.some(validation => validation.requiredValidation); + const showMark = isRequired && !label; const classNames = useMemo( () => sanitizeModuleRootClasses(styles, className, [ @@ -39,8 +40,13 @@ const FormField = (props: PropsWithRef) => {
{label && {label}} -
+
{children} + {showMark && ( + + )} {(error || helperText) && {error ?? helperText}}
diff --git a/src/lib/components/Form/FormFields/FormFieldGroup.tsx b/src/lib/components/Form/FormFields/FormFieldGroup.tsx index 4f539962..a0c29442 100644 --- a/src/lib/components/Form/FormFields/FormFieldGroup.tsx +++ b/src/lib/components/Form/FormFields/FormFieldGroup.tsx @@ -7,7 +7,7 @@ import { FieldContext } from "@/components/Form/context/FieldContext"; import { PropsWithRefAndChildren } from "../../../types"; import { FormFieldGroupProps } from "@/components/Form/FormFields/types"; import usePropsWithThemeDefaults from "../../../motif/hooks/usePropsWithThemeDefaults"; -import { sanitizeModuleRootClasses } from "../../../../utils/cssUtils"; +import { sanitizeModuleClasses, sanitizeModuleRootClasses } from "../../../../utils/cssUtils"; const FormFieldGroup = (props: PropsWithRefAndChildren) => { const formContext = useForm(); @@ -32,6 +32,7 @@ const FormFieldGroup = (props: PropsWithRefAndChildren(() => getInitialExternalError(name, disabled)); const isRequired = groupValidations?.some(validation => validation.requiredValidation); + const showMark = isRequired && !label; const classNames = useMemo( () => @@ -61,8 +62,13 @@ const FormFieldGroup = (props: PropsWithRefAndChildren
{label && {label}} -
+
{children}
+ {showMark && ( + + )} {(error || helperText) && {error ?? helperText}}
diff --git a/src/lib/components/PinCode/PinCode.tsx b/src/lib/components/PinCode/PinCode.tsx index 0d094566..bb815398 100644 --- a/src/lib/components/PinCode/PinCode.tsx +++ b/src/lib/components/PinCode/PinCode.tsx @@ -107,7 +107,7 @@ const PinCodeComponent = (p: PropsWithRef) => { const classNames = sanitizeModuleRootClasses(styles, className, [size, circle && "circle"]); return ( -
+
{renderPinCodeItems()}
); diff --git a/src/lib/components/PinCode/__snapshots__/PinCode.test.tsx.snap b/src/lib/components/PinCode/__snapshots__/PinCode.test.tsx.snap index e502f495..af8ae978 100644 --- a/src/lib/components/PinCode/__snapshots__/PinCode.test.tsx.snap +++ b/src/lib/components/PinCode/__snapshots__/PinCode.test.tsx.snap @@ -4,7 +4,7 @@ exports[`PinCode should render with only required props, have default prop value
) => { const classNames = sanitizeModuleRootClasses(styles, className, [orientation, size, inFormField && "inFormField"]); return ( -
+
{children}
); diff --git a/src/lib/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap b/src/lib/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap index a00432c2..6323bc7c 100644 --- a/src/lib/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +++ b/src/lib/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap @@ -4,7 +4,7 @@ exports[`RadioGroup should render with only required props, and have standard pr
) => { ]); return ( -
+
Date: Tue, 1 Dec 2026 10:31:12 +0300 Subject: [PATCH 5/5] fix: fix --- src/lib/components/Checkbox/Checkbox.module.scss | 2 +- src/lib/components/Form/FormFields/FormField.module.scss | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/components/Checkbox/Checkbox.module.scss b/src/lib/components/Checkbox/Checkbox.module.scss index c5eb6f1b..19bf056b 100644 --- a/src/lib/components/Checkbox/Checkbox.module.scss +++ b/src/lib/components/Checkbox/Checkbox.module.scss @@ -13,7 +13,7 @@ $sizes: (("xs", 18, 6, 4, 16, "0 0 23 23"), ("sm", 20, 8, 6, 18, "0 0 23 23"), ( .Root { display: inline-flex; vertical-align: bottom; - align-items: center; + align-items: flex-start; } .input { diff --git a/src/lib/components/Form/FormFields/FormField.module.scss b/src/lib/components/Form/FormFields/FormField.module.scss index 33127ac3..4a3d30da 100644 --- a/src/lib/components/Form/FormFields/FormField.module.scss +++ b/src/lib/components/Form/FormFields/FormField.module.scss @@ -117,8 +117,9 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6 } } -// The control and the mark share the first line, the helper wraps to the next one +// Edge case of labelless use where a required mark(asterisks) should also be placed: .withMark { + // The control and the mark share the first line, the helper wraps to the next one flex-flow: row wrap; align-items: flex-start;