feat(Accordion): Added isPlain and isNoPlainOnGlass prop to Accordion#12288
feat(Accordion): Added isPlain and isNoPlainOnGlass prop to Accordion#12288tlabaj wants to merge 10 commits intopatternfly:mainfrom
Conversation
|
Preview: https://pf-react-pr-12288.surge.sh A11y report: https://pf-react-pr-12288-a11y.surge.sh |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds two optional boolean props to the Accordion component— Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
isPlaindefault broadens behavior beyond explicit opt-out.With Line 34 defaulting
isPlaintofalse, Line 45 appliesnoPlainunder glass theme even when consumers omitisPlain. This conflicts with the “apply whenisPlain={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
📒 Files selected for processing (3)
packages/react-core/src/components/Accordion/Accordion.tsxpackages/react-core/src/components/Accordion/__tests__/Accordion.test.tsxpackages/react-core/src/helpers/util.ts
packages/react-core/src/components/Accordion/__tests__/Accordion.test.tsx
Outdated
Show resolved
Hide resolved
thatblindgeye
left a comment
There was a problem hiding this comment.
Looks good! Just wondering, are the other changes to the test file necessary to get tests to pass?
| asDefinitionList?: boolean; | ||
| /** Flag to indicate the accordion had a border */ | ||
| isBordered?: boolean; | ||
| /** Flag to prevent the accordion from automatically applying plain styling when glass theme is enabled. */ |
There was a problem hiding this comment.
Actually we may want to add the beta flag here similar to what Katie did in her Table PR
What: Closes #12276
isPlainprop to addpf-m-plainclass when setisNoPlainOnGlassprop that adds thepf-m-no-plainclass to prevent the accordion from automatically applying plain styling when glass theme is enabledSummary by CodeRabbit