Skip to content

Return undefined instead of null from class name helpers (#695) - #767

Merged
bedrich-schindler merged 1 commit into
masterfrom
refactoring/695
Oct 20, 2026
Merged

bedrich-schindler merged 1 commit into
masterfrom
refactoring/695

Conversation

@bedrich-schindler

@bedrich-schindler bedrich-schindler commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Class name helpers now return undefined instead of null when no class applies, and the rule is documented in the API Guidelines.
Closes #695

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-20 13:42 UTC

@adamkudrna adamkudrna left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this is a unification with the props approach, right?

@bedrich-schindler

Copy link
Copy Markdown
Contributor Author

So this is a unification with the props approach, right?

Yes. Side effect is that also fixed my statement from the #695:

The reason is simple. Output of those class name helpers are forwarded to ‘className’ prop. It can be passed into classNames() that transforms it to undefined anyway. But it can also be used directly as single class name and then we need to handle those situations because null is transformed to class. Undefined means that it is omit at all

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The changed fallback contract lacks the repository-required regression tests.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates class-name helpers to return undefined, matching React’s className type and API conventions.

Changes:

  • Replaces null fallbacks across ten class-name helpers.
  • Documents empty-value conventions.
  • Regression tests are missing.
File Description
src/​docs/​contribute/​api.md Documents empty-value rules.
src/​components/​Text/​_helpers/​getRootWordWrappingClassName.ts Returns undefined when unset.
src/​components/​Text/​_helpers/​getRootHyphensClassName.ts Returns undefined when unset.
src/​components/​Text/​_helpers/​getRootClampClassName.ts Returns undefined when unset.
src/​components/​Modal/​_helpers/​getScrollingClassName.ts Returns undefined when unset.
src/​components/​Modal/​_helpers/​getPositionClassName.ts Returns undefined when unset.
src/​components/​Button/​helpers/​getRootLabelVisibilityClassName.ts Returns undefined when unset.
src/​components/​_helpers/​getRootValidationStateClassName.ts Returns undefined when unset.
src/​components/​_helpers/​getRootSizeClassName.ts Returns undefined when unset.
src/​components/​_helpers/​getRootPriorityClassName.ts Returns undefined when unset.
src/​components/​_helpers/​getRootColorClassName.ts Returns undefined when unset.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/components/Text/_helpers/getRootWordWrappingClassName.ts
Comment thread src/docs/contribute/api.md
@bedrich-schindler
bedrich-schindler merged commit 0ad2daf into master Oct 20, 2026
13 checks passed
@bedrich-schindler
bedrich-schindler deleted the refactoring/695 branch October 20, 2026 13:42

This branch was successfully deployed

1 active deployment
pr-preview/pr-767 — 9742ca20 Deployed Oct 20, 2026 by bedrich-schindler via Deploy PR Preview #145
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.

Return undefined instead of null from class name helpers

4 participants