Skip to content

feat(Accordion): Added isPlain prop to Accordion#12288

Open
tlabaj wants to merge 5 commits intopatternfly:mainfrom
tlabaj:accordion_glass
Open

feat(Accordion): Added isPlain prop to Accordion#12288
tlabaj wants to merge 5 commits intopatternfly:mainfrom
tlabaj:accordion_glass

Conversation

@tlabaj
Copy link
Contributor

@tlabaj tlabaj commented Mar 23, 2026

What: Closes #12276

  • Added changes so Accordion adapts its styling when the PatternFly glass theme is active (pf-v6-theme-glass on the document root) and isPlain prop is false.
  • Added hasGlassTheme() utility fucntion to check whether pf-v6-theme-glass is present on document.documentElement.

Summary by CodeRabbit

  • New Features
    • Accordion gains an optional "plain" mode and now adjusts its styling when the glass theme is active.
  • Tests
    • Expanded test coverage to validate theme detection and the conditional styling behavior across plain/non-plain configurations.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Mar 23, 2026

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 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: 2ba997c5-5717-4592-adb0-959309283bf9

📥 Commits

Reviewing files that changed from the base of the PR and between fc5cf2f and a0e636c.

📒 Files selected for processing (1)
  • packages/react-core/src/components/Accordion/Accordion.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react-core/src/components/Accordion/Accordion.tsx

Walkthrough

Adds a new optional isPlain?: boolean prop to Accordion, a hasGlassTheme() helper that detects the glass theme on document.documentElement, and conditional application of the pf-m-no-plain modifier when isPlain is false and the glass theme is active; tests cover the permutations.

Changes

Cohort / File(s) Summary
Accordion Component
packages/react-core/src/components/Accordion/Accordion.tsx
Added isPlain?: boolean prop (default false) and updated root className to apply styles.modifiers.noPlain only when isPlain === false and hasGlassTheme() is true.
Tests
packages/react-core/src/components/Accordion/__tests__/Accordion.test.tsx
Updated imports and fragment usage; adjusted consumer expectations; added tests verifying presence/absence of styles.modifiers.noPlain across isPlain values and when pf-v6-theme-glass is toggled on document.documentElement.
Utilities
packages/react-core/src/helpers/util.ts
Added exported hasGlassTheme(): boolean which safely checks for pf-v6-theme-glass on document.documentElement.classList (returns false when document is undefined).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 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 main change: adding the isPlain prop to the Accordion component, which is the primary feature introduced in this PR.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements: adds isPlain prop that controls pf-m-no-plain class application, creates hasGlassTheme() utility to detect glass theme, and applies conditional styling when isPlain=false and glass theme is active.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue objectives: isPlain prop implementation, hasGlassTheme() utility, conditional class application, and comprehensive test coverage for the new behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@tlabaj tlabaj requested review from a team, dlabaj and nicolethoen and removed request for a team March 24, 2026 13:05
@tlabaj tlabaj marked this pull request as ready for review March 24, 2026 14:26
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/react-core/src/components/Accordion/Accordion.tsx (1)

34-45: ⚠️ Potential issue | 🟠 Major

isPlain default broadens behavior beyond explicit opt-out.

With Line 34 defaulting isPlain to false, Line 45 applies noPlain under glass theme even when consumers omit isPlain. This conflicts with the “apply when isPlain={false}” behavior in the PR objective.

Proposed fix
 export const Accordion: React.FunctionComponent<AccordionProps> = ({
@@
-  isPlain = false,
+  isPlain,
@@
-        !isPlain && hasGlassTheme() && styles.modifiers.noPlain,
+        isPlain === false && hasGlassTheme() && styles.modifiers.noPlain,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-core/src/components/Accordion/Accordion.tsx` around lines 34 -
45, The component currently defaults isPlain = false and uses !isPlain in the
className, which causes noPlain to be applied when the prop is omitted; update
the logic so noPlain is only applied when isPlain is explicitly false. Change
the className conditional from !isPlain && hasGlassTheme() to isPlain === false
&& hasGlassTheme() (or alternatively remove the default and set isPlain to
undefined) so styles.modifiers.noPlain is only added when the consumer passed
isPlain={false}; reference: prop isPlain, Accordion component,
styles.modifiers.noPlain, and hasGlassTheme().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/react-core/src/components/Accordion/__tests__/Accordion.test.tsx`:
- Around line 144-150: The test that adds the 'pf-v6-theme-glass' root class
(test named "Renders with class ${styles.modifiers.noPlain} when isPlain=false
and glass theme is applied") should guard cleanup with a try/finally: add the
class before rendering and put the render/assert inside a try block, then always
remove the class in the finally block to prevent leakage into other tests;
update the test that references Accordion and styles.modifiers.noPlain
accordingly.

---

Outside diff comments:
In `@packages/react-core/src/components/Accordion/Accordion.tsx`:
- Around line 34-45: The component currently defaults isPlain = false and uses
!isPlain in the className, which causes noPlain to be applied when the prop is
omitted; update the logic so noPlain is only applied when isPlain is explicitly
false. Change the className conditional from !isPlain && hasGlassTheme() to
isPlain === false && hasGlassTheme() (or alternatively remove the default and
set isPlain to undefined) so styles.modifiers.noPlain is only added when the
consumer passed isPlain={false}; reference: prop isPlain, Accordion component,
styles.modifiers.noPlain, and hasGlassTheme().

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b2854331-7f1e-4197-909a-6702d0712ea8

📥 Commits

Reviewing files that changed from the base of the PR and between 641c888 and ecbb0be.

📒 Files selected for processing (3)
  • packages/react-core/src/components/Accordion/Accordion.tsx
  • packages/react-core/src/components/Accordion/__tests__/Accordion.test.tsx
  • packages/react-core/src/helpers/util.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accordion - Glass style follow up

2 participants