-
Notifications
You must be signed in to change notification settings - Fork 378
feat(Toolbar): add flexGrow and widths props to ToolbarItem and Toolb… #12237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(Toolbar): add flexGrow and widths props to ToolbarItem and Toolb… #12237
Conversation
…arGroup - Add flexGrow prop to ToolbarItem with breakpoint support (default, sm, md, lg, xl, 2xl) - Add flexGrow prop to ToolbarGroup with breakpoint support - Add widths prop to ToolbarItem for setting custom widths at various breakpoints - Add comprehensive tests for new props - Add example documentation showing flexGrow and widths usage Fixes patternfly#11910 Co-authored-by: Cursor <cursoragent@cursor.com>
WalkthroughIntroduces responsive Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 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 |
|
Preview: https://pf-react-pr-12237.surge.sh A11y report: https://pf-react-pr-12237-a11y.surge.sh |
There was a problem hiding this 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/Toolbar/ToolbarItem.tsx (1)
210-222:⚠️ Potential issue | 🟠 MajorBug:
styleprop is now silently dropped for separator variant ToolbarItems.Before this change,
stylewas part of...propsand forwarded to<Divider>. Now thatstyleis explicitly destructured (Line 210) for the responsive-widths merge, it's no longer included in the rest props spread to the separator's<Divider>(Line 219). Anystylepassed to a<ToolbarItem variant="separator" style={...} />will be silently lost.Proposed fix — forward style to the Divider branch
return ( <Divider className={css(className)} orientation={{ default: 'vertical' }} + style={style} {...props} {...(isDividerRoleValid && { role: role as 'separator' | 'presentation' })} /> );
🤖 Fix all issues with AI agents
In
`@packages/react-core/src/components/Toolbar/examples/ToolbarFlexGrowAndWidths.tsx`:
- Line 6: The component definition uses React.FunctionComponent but React isn't
imported; fix by either importing React (e.g., add a default import for React)
so React.FunctionComponent is valid, or change the signature to use the named
FunctionComponent type and import it from 'react' (update the component
declaration ToolbarFlexGrowAndWidths to use FunctionComponent and add the
corresponding import). Ensure the import and the symbol used in the declaration
match.
🧹 Nitpick comments (2)
packages/react-core/src/components/Toolbar/examples/ToolbarFlexGrowAndWidths.tsx (2)
1-4: Use the public API import forSearchInputand consolidate imports.Line 4 uses a deep internal path (
@patternfly/react-core/dist/esm/components/SearchInput/SearchInput) which is fragile and bypasses the public API.SearchInputis exported from@patternfly/react-coreand can be co-imported withButtonand the Toolbar components. Additionally,Buttonon Line 3 can be merged into the Line 2 import.♻️ Proposed fix
import { Fragment } from 'react'; -import { Toolbar, ToolbarItem, ToolbarGroup, ToolbarContent } from '@patternfly/react-core'; -import { Button } from '@patternfly/react-core'; -import SearchInput from '@patternfly/react-core/dist/esm/components/SearchInput/SearchInput'; +import { Toolbar, ToolbarItem, ToolbarGroup, ToolbarContent, Button, SearchInput } from '@patternfly/react-core';
72-104: Consider using semantic heading elements for example section labels.The bare text nodes ("Using flexGrow on ToolbarItem", etc.) with
<br />spacers are not semantically meaningful. Using<h3>or<p>elements would improve readability in the rendered documentation.
Fixes #11910 : ToolbarItem - props for width and flex-grow
Summary by CodeRabbit
New Features
flexGrowprop to ToolbarGroup and ToolbarItem to enable flexible space distribution across breakpoints.widthsprop to ToolbarItem for dynamic width control at different breakpoints.Tests
Documentation