Skip to content

fix(css): return undefined if there is no className#11602

Open
logonoff wants to merge 1 commit into
patternfly:mainfrom
logonoff:flexitem
Open

fix(css): return undefined if there is no className#11602
logonoff wants to merge 1 commit into
patternfly:mainfrom
logonoff:flexitem

Conversation

@logonoff
Copy link
Copy Markdown
Member

@logonoff logonoff commented Mar 4, 2025

What: Closes #11590

Summary by CodeRabbit

  • Bug Fixes
    • The class generation utility now returns undefined for empty class lists instead of returning empty strings. This delivers more consistent and predictable behavior throughout your application. The updated function ensures that conditional styling scenarios function more reliably, reducing unexpected empty string occurrences and improving overall code consistency.

Review Change Stack

@patternfly-build
Copy link
Copy Markdown
Collaborator

patternfly-build commented Mar 4, 2025

@logonoff logonoff force-pushed the flexitem branch 2 times, most recently from 0d5a4ac to aad2153 Compare March 4, 2025 21:25
@dlabaj
Copy link
Copy Markdown
Contributor

dlabaj commented Mar 12, 2025

Waiting on breaking change release to merge this PR.

@github-actions
Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions Bot added the Stale label May 12, 2025
@logonoff logonoff force-pushed the flexitem branch 2 times, most recently from 233ee94 to a689f33 Compare October 30, 2025 16:14
@github-actions github-actions Bot removed the Stale label Nov 4, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 9, 2026

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions Bot added the Stale label Jan 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5de3b4aa-a220-4de4-a224-c07e6440c678

📥 Commits

Reviewing files that changed from the base of the PR and between 9e88adf and e267321.

⛔ Files ignored due to path filters (6)
  • packages/react-core/src/components/List/__tests__/__snapshots__/ListItem.test.tsx.snap is excluded by !**/*.snap
  • packages/react-core/src/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap is excluded by !**/*.snap
  • packages/react-core/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap is excluded by !**/*.snap
  • packages/react-core/src/components/ToggleGroup/__tests__/__snapshots__/ToggleGroupItemElement.test.tsx.snap is excluded by !**/*.snap
  • packages/react-core/src/layouts/Flex/__tests__/__snapshots__/Flex.test.tsx.snap is excluded by !**/*.snap
  • packages/react-drag-drop/src/components/DragDrop/__tests__/__snapshots__/DragDrop.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • packages/react-styles/src/index.ts

Walkthrough

The css helper function in packages/react-styles/src/index.ts is updated to declare a return type of string | undefined and to return undefined when the computed class list is empty instead of an empty string. This prevents rendering of empty class="" attributes.

Changes

css Helper Return Type Update

Layer / File(s) Summary
css function signature and empty class handling
packages/react-styles/src/index.ts
The css function return type is updated to string | undefined, and its implementation changes to return undefined when the joined class string is empty, replacing the previous empty string behavior.

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: updating the css function to return undefined instead of an empty string when no classNames are provided.
Linked Issues check ✅ Passed The code change directly addresses the linked issue #11590 by modifying the css function to return undefined when the class list is empty, enabling the omission of empty class attributes in rendered HTML.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the css function's return type and behavior, with no unrelated modifications present in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Bug - react-styles - When the css helper has no valid classNames, it still includes the attribute when rendered

5 participants