Skip to content

fix(Form): show the required mark on fields without a label - #253

Merged
hatesalp merged 8 commits into
mainfrom
fix/form_required
Dec 1, 2026
Merged

hatesalp merged 8 commits into
mainfrom
fix/form_required

Conversation

@hatesalp

@hatesalp hatesalp commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

A FormField / FormFieldGroup without a label could not show the required mark. It is now drawn in CSS at the top
right of the input (for groups: the last item when horizontal, the first when vertical).

  • Selected with .required:not([data-has-label]); no markup change in FormField.
  • Checkbox, Switch, RadioGroup and PinCode get data-mtf-component and keep their content width, so the mark follows
    their text.
  • The asterisk is defined once as $required-mark.
  • InputNumber: overflow: hidden clipped the mark. The spinner buttons now inherit the root's radius (pill included),
    so it is removed.

Type of Change

  • 🆕 New Component
  • ✨ Feature / Enhancement
  • 🐛 Bug Fix
  • 💥 Breaking Change
  • 📦 Build / Dependency / Docs Update
  • 🧹 Code Refactoring

Screenshots / Preview

image image

Checklist

  • Self-reviewed, no leftover logs or debug code
  • Uses design tokens — no hardcoded style values
  • Accessible (keyboard nav, ARIA, contrast)
  • Tests added/updated and passing
  • Storybook story added/updated

How to Test

Test data can be taken from the Storybook Form story (Components/Form › Primary): copy its fields and remove their
label props.

@hatesalp
hatesalp requested a review from a team November 26, 2026 08:26

@atakanbayrak atakanbayrak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After conflict resolution I will be here.

@claude

claude Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @aktasmehmet's task in 36s —— View job


Review of PR #253: required mark on fields without a label

I read the diff against docs/review/general.md, tests.md and css.md. .Root is intact in both touched modules. FormField.module.scss still has .Root as its first rule. InputNumber.module.scss keeps .Root through retain-scoped-class. So there is no §0 blocker.

I did not run tests, lint or the build, and I did not check the visuals in Storybook. This is a read-only review of the diff.

Findings

  1. The PR description does not match the code. The description says the mark is drawn in CSS with .required:not([data-has-label]), with "no markup change in FormField". It also mentions data-mtf-component and a $required-mark variable. The code instead renders a <span class="mark" aria-hidden>*</span> and adds .withMark to inputContainer. The attribute is data-mtf-inline-control, and there is no $required-mark. Please update the description. The earlier specificity review on :not([data-has-label]) no longer applies to this implementation.

  2. Redundant disabled rule. This is css.md §4 (declare a value once). In FormField.module.scss, .label still has .disabled &, .disabled &::after { color: text-disabled }. ::after now reads --mtf-form-field-helper-color, and .disabled already sets that variable to the same value. Keep only .disabled & for the label text and drop .disabled &::after.

  3. Success now colors the label asterisk. Before, the label's ::after was only softer, danger or disabled. Now it also turns success-text through the shared variable. The reviewer asked for the colors to behave together, so this may be intended. Please confirm with design that a green * on a successful field is wanted.

  4. The asterisk is defined in two places. The label uses content: "*" in CSS. The no-label case renders a literal * in the JSX of both FormField.tsx and FormFieldGroup.tsx. I would not block on this. The showMark = isRequired && !label logic and the span markup are also duplicated between those two components. A small shared RequiredMark component, or a shared helper, would keep them in sync.

  5. Unrelated reformatting adds noise.

    • Checkbox.module.scss collapses the multi-line $sizes table into one line, which is harder to read.
    • InputText.module.scss expands one-line rules.

    Both should be reverted so the diff only holds the fix.

  6. Missing tests. The checklist says tests were added, but the only test changes are four snapshot updates for the new data-mtf-inline-control attribute. There is no test that a required FormField or FormFieldGroup without a label renders the mark. There is also no test that it is absent when a label is present or when the field is not required. src/lib/components/Form/test/Form.test.tsx is the natural place. Per tests.md §1, keep these out of the defaults test.

  7. Checkbox alignment change affects every use. align-items: center became flex-start on .Root, which is not limited to form fields. Standalone checkboxes with multi-line labels will shift. Please verify the box still lines up with the first line of text at every size. Also check this against inFormField, which uses paddingV.

  8. .withMark selectors. > .groupItems:not(:has(> :not([data-mtf-inline-control]))) works out to about 0,3,0, right at the limit for migrated components (css.md header). Sass nesting is fine. Be aware that any wrapped child, such as a tooltip around a Checkbox, makes the group fall back to full width, so the mark moves to the row end. That is acceptable but worth knowing.

  9. InputNumber overflow: hidden removal. The reasoning in the thread is sound if the spinner buttons really inherit the root radius, including pill. I couldn't verify it from the diff, so please check it visually in Storybook for all radius values.

Summary

The approach is reasonable and has no blockers. Findings 5 and 6 are the ones to address before merge. Items 2 and 7 are worth a quick fix or check.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Size Change: +485 B (+0.17%)

Total Size: 284 kB

📦 View Changed
Filename Size Change
dist/index.cjs 142 kB +250 B (+0.18%)
dist/index.es.js 140 kB +235 B (+0.17%)
ℹ️ View Unchanged
Filename Size
dist/chunks/useToggle-1pe2WRaw.js 800 B
dist/chunks/useToggle-B6kbi656.cjs 769 B
dist/hooks.cjs 225 B
dist/hooks.es.js 219 B

compressed-size-action

@hatesalp
hatesalp merged commit 7f16657 into main Dec 1, 2026
12 of 13 checks passed
@hatesalp
hatesalp deleted the fix/form_required branch December 1, 2026 07:50

This branch is waiting to be deployed

1 waiting deployment
development — a0e50817 Waiting Dec 1, 2026 by aktasmehmet via Chromatic #584
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants