Skip to content

Conversation

@khadesamrudhi
Copy link

@khadesamrudhi khadesamrudhi commented Oct 20, 2025

This PR adds the previously removed widths prop to <ToolbarItem /> and introduces a new flexGrow prop that maps to .pf-m-flex-grow[on-{breakpoint}] modifiers.

Changes

  • Added responsive widths and flexGrow support using formatBreakpointMods
  • Updated unit tests to verify classnames
  • All ToolbarItem tests passing ✅

Closes #11910

Summary by CodeRabbit

  • New Features
    • Added responsive width and flex-grow layout modifiers to Toolbar components for finer layout control across breakpoints.
    • Demo updated to include a Toolbar item showcasing the new width and flexGrow options.

✏️ Tip: You can customize this high-level summary in your review settings.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Oct 20, 2025

@khadesamrudhi khadesamrudhi changed the title fix(ToolbarItem): add width and flex-grow props and handle breakpoint… fix(Toolbar): add width and flex-grow props to ToolbarItem; add flex-grow to ToolbarGroup; update demo and tests Oct 23, 2025
@khadesamrudhi
Copy link
Author

khadesamrudhi commented Oct 23, 2025

First-time contributor, could a maintainer please approve workflows and re-run the failed job?

Notes:

  • The TypeScript parse error in packages/tsconfig.base.json was fixed.
  • Remaining failure is a transient Surge preview upload DNS error (EAI_AGAIN), unrelated to code changes.
  • Changes are limited to ToolbarItem widths + flexGrow, ToolbarGroup flexGrow, tests, demo, and types/global.d.ts.

Thanks!

@mcoker @kmcfaul @thatblindgeye

@khadesamrudhi
Copy link
Author

I’ve fixed the packages/tsconfig.base.json JSON issue and pushed the update. Could you please approve the workflows and re-run the CI? If Surge preview shows EAI_AGAIN, it indicates a transient network error that we can retry. Thanks!

@khadesamrudhi
Copy link
Author

Hi, all automated checks have passed.
Requesting a review when convenient.
Please let me know if any additional changes are needed. Thank you.
@mcoker @thatblindgeye @kmcfaul

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Some comments below. Additionally, there are several files updates not related to the issue. If those updates aren't necessary for the flexGrow and widths updates being made here, I might suggest pulling those out in favor of a separate issue (if they're more enhancements you feel would be good for the codebase for example)

Comment on lines 246 to 261
widths &&
Object.entries(widths).reduce(
(acc, [bp, size]) => ({
...acc,
[`pf-m-w-${size}${bp !== 'default' ? `-on-${bp}` : ''}`]: true
}),
{}
),
flexGrow &&
Object.entries(flexGrow).reduce(
(acc, [bp]) => ({
...acc,
[`pf-m-flex-grow${bp !== 'default' ? `-on-${bp}` : ''}`]: true
}),
{}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to above, we should be able to just use our formatBreakpointMods util function instead

Copy link
Contributor

@thatblindgeye thatblindgeye Oct 28, 2025

Choose a reason for hiding this comment

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

Just an addendum to this, we should use the formatBreakpointMods function for the flexGrow here, but for handling applying the widths prop we should basically just add back in what was removed in this React PR https://github.com/patternfly/patternfly-react/pull/10022/files#diff-7beeea05e52252eb360f045d661fab89fe634b00becfd8a3dbaa48338c6032c0 (we want to apply a styles object rather than a class)

@@ -0,0 +1,40 @@
import { useState } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Was there an intention to add Cypress tests for this demo? Not entirely sure we need one to test the new props, so my feeling is we could remove this demo file and revert the changes made to the ToolbarDemo/ToolbarDemo.tsx file.

Comment on lines +14 to +18
describe('ToolbarGroup flexGrow', () => {
const bps = ['default', 'sm', 'md', 'lg', 'xl', '2xl'];

describe.each(bps)('flexGrow at various breakpoints', (bp) => {
it(`should render with pf-m-flex-grow when flexGrow is set at ${bp}`, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We typically use the describe block a bit more rarely in our codebase, in this case I'm not sure we should use it. Instead what we could do is put the breakpoints variable as a global var or within the first describe('ToolbarGroup' ... block, then:

  • Move the flexGrow and widths tests inside that block
  • remove the nested describe blocks being used here
  • instead, just run a forEach over the breakpoints array and call the tests in this forEach block

We do something similar in some of our unit test files, such as our Button tests:

Object.values(ButtonVariant).forEach((variant) => {
if (variant !== 'primary') {
test(`Does not render with class ${styles.modifiers[variant]} by default`, () => {
render(<Button>Not {variant} Button</Button>);
expect(screen.getByRole('button')).not.toHaveClass(styles.modifiers[variant]);
});
}
test(`Renders with class ${styles.modifiers[variant]} when variant=${variant}`, () => {
render(<Button variant={variant}>{variant} Button</Button>);
expect(screen.getByRole('button')).toHaveClass(styles.modifiers[variant]);
});
});

khadesamrudhi and others added 3 commits November 9, 2025 11:44
… flexGrow via formatBreakpointMods; update ToolbarItem tests; remove extra demo
… flexGrow via formatBreakpointMods; update JSDoc and tests
@khadesamrudhi
Copy link
Author

Pushed updates to fix review feedback:

  • ToolbarItem: widths applied via setBreakpointCssVars using base token c_toolbar__item_Width; flexGrow via formatBreakpointMods; removed hardcoded data-testid; JSDoc clarifies flexGrow=1.
  • ToolbarGroup: flexGrow via formatBreakpointMods; JSDoc updated.
  • Tests: ToolbarItem width tests assert CSS var per breakpoint.

No extra demo files included.
Previous CI errors from missing react-tokens imports should be resolved. Could you please approve the workflow run so CI can proceed?

@thatblindgeye @mcoker @kmcfaul

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Couple more change requests below. Also looks like there's still some unrelated file updates being made:

  • .yarnrc.yml should be reverted
  • cleanup.js should be removed
  • eslint.config.mjs should be reverted
  • packager.json should be reverted
  • ToolbarDemo.tsx should be reverted
  • tsconfig.base.json should be reverted
  • build-single-packages.mjs should be reverted
  • global.d.ts should be removed

The updates/additions of those files shouldn't be necessary for this PR

Comment on lines 250 to 276
style={{
...style,
...(widths
? setBreakpointCssVars(
Object.entries(widths).reduce(
(acc, [bp, size]) => {
if (!size) {
return acc;
}
const cssVarValueMap: Record<string, string> = {
sm: 'var(--pf-c-toolbar__item--m-w-sm--Width)',
md: 'var(--pf-c-toolbar__item--m-w-md--Width)',
lg: 'var(--pf-c-toolbar__item--m-w-lg--Width)',
xl: 'var(--pf-c-toolbar__item--m-w-xl--Width)',
'2xl': 'var(--pf-c-toolbar__item--m-w-2xl--Width)',
'3xl': 'var(--pf-c-toolbar__item--m-w-3xl--Width)',
'4xl': 'var(--pf-c-toolbar__item--m-w-4xl--Width)'
};
const value = cssVarValueMap[size as keyof typeof cssVarValueMap];
return value ? { ...acc, [bp]: value } : acc;
},
{} as Record<string, string>
),
(c_toolbar__item_Width as any).name
)
: undefined)
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to the above comment, we'll need to tweak this and we can simplify it a bit :

Suggested change
style={{
...style,
...(widths
? setBreakpointCssVars(
Object.entries(widths).reduce(
(acc, [bp, size]) => {
if (!size) {
return acc;
}
const cssVarValueMap: Record<string, string> = {
sm: 'var(--pf-c-toolbar__item--m-w-sm--Width)',
md: 'var(--pf-c-toolbar__item--m-w-md--Width)',
lg: 'var(--pf-c-toolbar__item--m-w-lg--Width)',
xl: 'var(--pf-c-toolbar__item--m-w-xl--Width)',
'2xl': 'var(--pf-c-toolbar__item--m-w-2xl--Width)',
'3xl': 'var(--pf-c-toolbar__item--m-w-3xl--Width)',
'4xl': 'var(--pf-c-toolbar__item--m-w-4xl--Width)'
};
const value = cssVarValueMap[size as keyof typeof cssVarValueMap];
return value ? { ...acc, [bp]: value } : acc;
},
{} as Record<string, string>
),
(c_toolbar__item_Width as any).name
)
: undefined)
}}
style={{
...style,
...(widths ? setBreakpointCssVars(widths, c_toolbar__item_Width.name) : undefined)
}}

Out of curiosity, where did the --pf-c-toolbar__item--m-w-xl--Width etc strings come from?

Comment on lines 23 to 28
default?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
sm?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
md?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
lg?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
xl?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
'2xl'?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
Copy link
Contributor

Choose a reason for hiding this comment

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

For this prop, we want the types to be just string, e.g. default?: string, as the expectation is that a consumer would pass a unit value for this prop like widths={{sm: '3rem'}} rather than us setting a token.

Suggested change
default?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
sm?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
md?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
lg?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
xl?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
'2xl'?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
default?: string;
sm?: string;
md?: string;
lg?: string;
xl?: string;
'2xl'?: string;

@thatblindgeye
Copy link
Contributor

@khadesamrudhi it doesn't look like the previous comments have been addressed, can you confirm if you have the changes locally but haven't pushed them yet?

@khadesamrudhi
Copy link
Author

@khadesamrudhi it doesn't look like the previous comments have been addressed, can you confirm if you have the changes locally but haven't pushed them yet?

Apologies for the oversight on my part. I'll be working on this and will updated you soon with the channges. Thanks for pointing it out and for your patience.

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Walkthrough

Adds responsive width and flexGrow props to Toolbar components, introduces global TypeScript module declarations, updates ESLint and Yarn/build configuration, adds a cleanup script, normalizes build paths for Windows, and adds tests and a demo usage for the new Toolbar props.

Changes

Cohort / File(s) Summary
Yarn & Project Config
\.yarnrc.yml, package.json, packages/tsconfig.base.json
Added Yarn HTTP retry/timeout and npm registry entries; added eslint-plugin-patternfly-react devDependency; added typeRoots to tsconfig.base.json.
Build & Cleanup Scripts
cleanup.js, scripts/build-single-packages.mjs
New cleanup.js recursively deletes node_modules/.yarn and related files; build-single-packages.mjs now normalizes Windows-style paths and adds an early exit when componentName cannot be derived.
ESLint Configuration
eslint.config.mjs
Dynamic import of eslint-plugin-patternfly-react with fallback, safer extraction of Prettier recommended config, explicit no-unused-vars: 'off' base rule, and inclusion of Prettier plugin wiring changes.
Global Type Declarations
types/global.d.ts
New global TypeScript declarations for PatternFly CSS modules, react-styles helpers, icon components, token values, and a *.css shim.
Toolbar — Code
packages/react-core/src/components/Toolbar/ToolbarGroup.tsx, packages/react-core/src/components/Toolbar/ToolbarItem.tsx
Added flexGrow prop to ToolbarGroup; added widths and flexGrow props to ToolbarItem; applies breakpoint modifiers and sets CSS vars via setBreakpointCssVars using c_toolbar__item_Width token.
Toolbar — Tests
packages/react-core/src/components/Toolbar/__tests__/ToolbarGroup.test.tsx, packages/react-core/src/components/Toolbar/__tests__/ToolbarItem.test.tsx
Added parameterized tests for flexGrow across breakpoints and widths CSS variable assertions.
Demo
packages/react-integration/demo-app-ts/src/components/demos/ToolbarDemo/ToolbarDemo.tsx
Adjusted event type imports/annotations and added a ToolbarItem example using widths and flexGrow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • thatblindgeye
  • mcoker
  • lboehling
  • nicolethoen
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive While most changes align with #11910 objectives, several files appear tangential: .yarnrc.yml configuration, cleanup.js script, eslint config updates, and tsconfig type resolution changes are not directly required by the linked issue requirements. Clarify whether .yarnrc.yml, cleanup.js, eslint.config.mjs, package.json (eslint-plugin-patternfly-react), and tsconfig modifications are preparatory infrastructure changes or separate concerns that could be split into a separate PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main changes: adding width and flex-grow props to ToolbarItem, adding flex-grow to ToolbarGroup, and updating demos and tests.
Linked Issues check ✅ Passed The PR successfully addresses all requirements from #11910: restores the widths prop for ToolbarItem [#11910], adds flexGrow prop for responsive modifiers to both ToolbarItem and ToolbarGroup [#11910], implements responsive behavior via formatBreakpointMods and setBreakpointCssVars [#11910], and updates tests and demo accordingly [#11910].

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

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: 3

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/__tests__/ToolbarItem.test.tsx (1)

15-15: Typo in describe block name: "ToobarItem" should be "ToolbarItem".

🔤 Suggested fix
-  describe('ToobarItem rowWrap', () => {
+  describe('ToolbarItem rowWrap', () => {
🤖 Fix all issues with AI agents
In `@packages/react-core/src/components/Toolbar/__tests__/ToolbarGroup.test.tsx`:
- Line 30: The describe block title contains a typo; update the test suite name
in the describe call in ToolbarGroup.test.tsx from "ToobarGroup rowWrap" to
"ToolbarGroup rowWrap" so the test description accurately references the
ToolbarGroup component (locate the describe(...) string in the file and correct
the spelling).

In `@types/global.d.ts`:
- Around line 34-37: The module declaration for
'@patternfly/react-tokens/dist/esm/*' incorrectly types token exports as plain
strings; update it to export the actual token object shape used across the
codebase (e.g., an interface with properties name: string; value: string |
number; var: string) and change the exported symbol (currently tokenValue) to
that type so imports in components like ToolbarItem.tsx no longer require `as
any` casts; specifically modify the declaration in types/global.d.ts to export
the correct token interface/type for all matching modules.
- Around line 23-32: The declaration for module
'@patternfly/react-icons/dist/esm/icons/*-icon' is incorrect: replace the
FunctionComponent type and custom size prop with the correct ComponentClass
using PatternFly's SVGIconProps; update the import to use ComponentClass from
'react' and SVGIconProps from '@patternfly/react-icons', change the exported
Icon symbol to be typed as ComponentClass<SVGIconProps>, and remove the size
property from the prop shape so icons accept the standard SVG/HTML props plus
title and className.
♻️ Duplicate comments (1)
packages/react-core/src/components/Toolbar/ToolbarItem.tsx (1)

21-29: Widths prop type may conflict with reviewer feedback.

The past review comment from thatblindgeye indicated that the widths prop types should be string (e.g., default?: string) so consumers can pass unit values like widths={{ sm: '3rem' }} directly. The current implementation uses predefined size tokens ('sm' | 'md' | 'lg' etc.) that map to internal CSS variables.

If the intent is to allow arbitrary width values, the types should be changed to string. If the intent is to constrain to predefined sizes, please confirm this with the reviewer.

🧹 Nitpick comments (6)
cleanup.js (2)

11-15: Silent error suppression may mask legitimate failures.

Catching and ignoring all errors without any logging makes debugging difficult when cleanup fails unexpectedly (e.g., due to file locks, permissions, or EBUSY errors). Consider at least logging at a debug level or providing a --verbose flag.


4-24: Replace fs.rmdirSync with fs.rmSync to use modern Node.js API.

fs.rmdirSync is deprecated (DEP0147). The entire deleteFolderRecursive function can be simplified using fs.rmSync with { recursive: true, force: true }, which handles all deletion in a single call:

function deleteFolderRecursive(pathToDelete) {
  try {
    fs.rmSync(pathToDelete, { recursive: true, force: true });
  } catch (err) {
    // Silently ignore errors (e.g., permission issues)
  }
}

The force: true option eliminates the need for the fs.existsSync check, and the recursive: true option handles nested files and directories without manual recursion.

eslint.config.mjs (1)

24-41: Defensive extraction from prettier config is reasonable but verbose.

The IIFE safely extracts only flat-config-compatible keys from the prettier plugin's recommended config. While the nested try/catch and null checks are verbose, they provide resilience against plugin changes.

Consider simplifying slightly if the cfg && typeof cfg === 'object' guard is sufficient:

♻️ Minor simplification
 const prettierRecommended = (() => {
-  try {
-    const cfg = prettier && prettier.configs && prettier.configs.recommended;
-    if (cfg && typeof cfg === 'object') {
-      return {
-        rules: cfg.rules || {},
-        settings: cfg.settings || {},
-        languageOptions: cfg.languageOptions || {}
-      };
-    }
-  } catch (e) {
-    // swallow — we'll just not include it
-  }
-  return null;
+  const cfg = prettier?.configs?.recommended;
+  if (cfg && typeof cfg === 'object') {
+    return {
+      rules: cfg.rules || {},
+      settings: cfg.settings || {},
+      languageOptions: cfg.languageOptions || {}
+    };
+  }
+  return null;
 })();
packages/react-core/src/components/Toolbar/ToolbarItem.tsx (1)

250-276: Consider simplifying the style computation and removing the as any cast.

The (c_toolbar__item_Width as any).name cast on line 273 suggests a type mismatch. The token import should provide a typed object with a name property. If the type definition is incomplete, consider augmenting it rather than using as any.

Additionally, the cssVarValueMap is recreated on every render. Consider hoisting it outside the component for minor performance optimization.

♻️ Suggested improvement
+const cssVarValueMap: Record<string, string> = {
+  sm: 'var(--pf-c-toolbar__item--m-w-sm--Width)',
+  md: 'var(--pf-c-toolbar__item--m-w-md--Width)',
+  lg: 'var(--pf-c-toolbar__item--m-w-lg--Width)',
+  xl: 'var(--pf-c-toolbar__item--m-w-xl--Width)',
+  '2xl': 'var(--pf-c-toolbar__item--m-w-2xl--Width)',
+  '3xl': 'var(--pf-c-toolbar__item--m-w-3xl--Width)',
+  '4xl': 'var(--pf-c-toolbar__item--m-w-4xl--Width)'
+};
+
 export const ToolbarItem: React.FunctionComponent<ToolbarItemProps> = ({

Then use cssVarValueMap directly in the style computation.

packages/react-core/src/components/Toolbar/__tests__/ToolbarGroup.test.tsx (1)

14-28: Test structure follows existing patterns but duplicates bps array.

The flexGrow tests follow the same describe.each pattern as the existing rowWrap tests, which maintains consistency within this file. Note that the bps array is declared twice (lines 15 and 31). Consider extracting it to a shared constant at the top of the describe block.

♻️ Suggested improvement
 describe('ToolbarGroup', () => {
+  const bps = ['default', 'sm', 'md', 'lg', 'xl', '2xl'];
+
   it('should render with pf-m-overflow-container when isOverflowContainer is set', () => {
     // ...
   });

   describe('ToolbarGroup flexGrow', () => {
-    const bps = ['default', 'sm', 'md', 'lg', 'xl', '2xl'];
-
     describe.each(bps)('flexGrow at various breakpoints', (bp) => {
       // ...
     });
   });

   describe('ToobarGroup rowWrap', () => {
-    const bps = ['default', 'sm', 'md', 'lg', 'xl', '2xl'];
-
     describe.each(bps)(`rowWrap at various breakpoints`, (bp) => {
       // ...
     });
   });
 });
scripts/build-single-packages.mjs (1)

57-61: Inconsistent use of component vs comp in path calculations.

Line 59 uses the original component variable while lines 60-61 use the normalized comp. Although path.normalize should handle backslashes, using comp consistently would be clearer and more predictable.

♻️ Suggested fix for consistency
   const pathAsArray = comp.split('/');
   const destDir = path.normalize(destFile.replace(/package\.json$/, ''));
-  const esmRelative = path.relative(destDir, path.normalize(component));
+  const esmRelative = path.relative(destDir, path.normalize(comp));
   const cjsRelative = path.relative(destDir, path.normalize(comp.replace('/dist/esm/', '/dist/js/')));
   const typesRelative = path.relative(destDir, path.normalize(comp.replace(/\.js$/, '.d.ts')));

});
});

describe('ToobarGroup rowWrap', () => {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Typo in describe block name: "ToobarGroup" should be "ToolbarGroup".

🔤 Suggested fix
-  describe('ToobarGroup rowWrap', () => {
+  describe('ToolbarGroup rowWrap', () => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
describe('ToobarGroup rowWrap', () => {
describe('ToolbarGroup rowWrap', () => {
🤖 Prompt for AI Agents
In `@packages/react-core/src/components/Toolbar/__tests__/ToolbarGroup.test.tsx`
at line 30, The describe block title contains a typo; update the test suite name
in the describe call in ToolbarGroup.test.tsx from "ToobarGroup rowWrap" to
"ToolbarGroup rowWrap" so the test description accurately references the
ToolbarGroup component (locate the describe(...) string in the file and correct
the spelling).

Comment on lines +23 to +32
declare module '@patternfly/react-icons/dist/esm/icons/*-icon' {
import type { FunctionComponent, SVGProps } from 'react';
const Icon: FunctionComponent<
SVGProps<SVGSVGElement> & {
title?: string;
size?: 'sm' | 'md' | 'lg' | 'xl';
}
>;
export default Icon;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, check if PatternFly is in the repository
find . -name "package.json" -type f -not -path "*/node_modules/*" | head -5

Repository: patternfly/patternfly-react

Length of output: 274


🏁 Script executed:

# Check for PatternFly icons in dependencies
grep -r "patternfly/react-icons" . --include="package.json" 2>/dev/null | head -10

Repository: patternfly/patternfly-react

Length of output: 647


🏁 Script executed:

# Look for icon files in the project
fd -t f "icon" --extension ts --extension tsx --extension d.ts | grep -i patternfly | head -20

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Search for any imports or references to PatternFly icons in the codebase
rg "@patternfly/react-icons" --type ts --type tsx -l | head -20

Repository: patternfly/patternfly-react

Length of output: 98


🏁 Script executed:

# List contents of react-icons package
ls -la ./packages/react-icons/

Repository: patternfly/patternfly-react

Length of output: 826


🏁 Script executed:

# Find icon component files
find ./packages/react-icons -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.d.ts" \) | head -20

Repository: patternfly/patternfly-react

Length of output: 205


🏁 Script executed:

# Check for icon definitions in the package
find ./packages/react-icons -name "*icon*" -type f | head -30

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Look for an example icon file to examine its structure
fd "Icon" ./packages/react-icons --type f --extension ts --extension js | head -10

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Examine the createIcon function which likely defines the icon component interface
cat -n ./packages/react-icons/src/createIcon.tsx

Repository: patternfly/patternfly-react

Length of output: 2569


🏁 Script executed:

# Check the main index file
cat -n ./packages/react-icons/src/index.ts

Repository: patternfly/patternfly-react

Length of output: 108


🏁 Script executed:

# Check if there are type definitions
find ./packages/react-icons -name "*.d.ts" -type f

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Look for dist folders or built icons
find ./packages/react-icons -name "dist" -o -name "esm" -type d

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Check for actual icon files (they might be generated)
find ./packages/react-icons/src -type f -name "*-icon*" | head -10

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Look for icons directory
ls -la ./packages/react-icons/src/icons/ 2>/dev/null | head -20

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Check the build/scripts to see how icons are generated
cat ./packages/react-icons/scripts/build-icons.js 2>/dev/null || cat ./packages/react-icons/scripts/*.js 2>/dev/null | head -50

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Check package.json in react-icons for build scripts
cat ./packages/react-icons/package.json

Repository: patternfly/patternfly-react

Length of output: 1534


🏁 Script executed:

# Search more broadly for icon files
find ./packages/react-icons -type f | head -30

Repository: patternfly/patternfly-react

Length of output: 1037


🏁 Script executed:

# Check if there's a build output or if icons come from elsewhere
ls -la ./packages/react-icons/src/

Repository: patternfly/patternfly-react

Length of output: 362


🏁 Script executed:

# Look at the README for documentation
cat ./packages/react-icons/README.md

Repository: patternfly/patternfly-react

Length of output: 3037


🏁 Script executed:

# Check the writeIcons script to see what types are generated
head -100 ./packages/react-icons/scripts/writeIcons.mjs

Repository: patternfly/patternfly-react

Length of output: 3243


Remove size prop and correct component type to ComponentClass.

The type declaration is inaccurate. Generated icons are ComponentClass<SVGIconProps>, not FunctionComponent, and they don't support a size prop. The correct declaration should be:

declare module '@patternfly/react-icons/dist/esm/icons/*-icon' {
  import type { ComponentClass } from 'react';
  import type { SVGIconProps } from '@patternfly/react-icons';
  const Icon: ComponentClass<SVGIconProps>;
  export default Icon;
}

Icons support all HTMLProps<SVGElement> attributes (except ref) plus title and className.

🤖 Prompt for AI Agents
In `@types/global.d.ts` around lines 23 - 32, The declaration for module
'@patternfly/react-icons/dist/esm/icons/*-icon' is incorrect: replace the
FunctionComponent type and custom size prop with the correct ComponentClass
using PatternFly's SVGIconProps; update the import to use ComponentClass from
'react' and SVGIconProps from '@patternfly/react-icons', change the exported
Icon symbol to be typed as ComponentClass<SVGIconProps>, and remove the size
property from the prop shape so icons accept the standard SVG/HTML props plus
title and className.

Comment on lines +34 to +37
declare module '@patternfly/react-tokens/dist/esm/*' {
const tokenValue: string;
export default tokenValue;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, check if node_modules exists and examine token export
ls -la node_modules/@patternfly/react-tokens/dist/esm/ 2>/dev/null | head -20

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Look for token files in the repository (they might be packaged or referenced)
find . -type f -name "*c_toolbar__item_Width*" 2>/dev/null | head -10

Repository: patternfly/patternfly-react

Length of output: 53


🏁 Script executed:

# Check the current global.d.ts file to see the exact type declaration
cat -n types/global.d.ts

Repository: patternfly/patternfly-react

Length of output: 1511


🏁 Script executed:

# Search for ToolbarItem.tsx and the as any cast mentioned
find . -type f -name "ToolbarItem.tsx" 2>/dev/null | head -5

Repository: patternfly/patternfly-react

Length of output: 131


🏁 Script executed:

# Search for 'as any' usage related to tokens in the codebase
rg "as any" --type typescript --type tsx -B 2 -A 2

Repository: patternfly/patternfly-react

Length of output: 105


🏁 Script executed:

cat -n packages/react-core/src/components/Toolbar/ToolbarItem.tsx

Repository: patternfly/patternfly-react

Length of output: 11722


🏁 Script executed:

# Search for token imports and 'as any' usage in tsx/ts files
rg "as any" -A 2 -B 2 --glob "*.tsx" --glob "*.ts"

Repository: patternfly/patternfly-react

Length of output: 50384


🏁 Script executed:

# Search for `@patternfly/react-tokens` imports in the codebase
rg "@patternfly/react-tokens" --glob "*.tsx" --glob "*.ts"

Repository: patternfly/patternfly-react

Length of output: 50384


🏁 Script executed:

# Try to understand the actual structure of react-tokens by searching package info or types
rg "tokenValue|token.*name.*value.*var" --glob "*.d.ts" --glob "*.ts"

Repository: patternfly/patternfly-react

Length of output: 329


Fix the token type declaration to match the actual token object structure.

The @patternfly/react-tokens exports objects with { name: string; value: string | number; var: string } properties, not plain strings. The current type declaration is incorrect, which is why as any casts are needed in ToolbarItem.tsx and elsewhere.

🔧 Suggested fix
 declare module '@patternfly/react-tokens/dist/esm/*' {
-  const tokenValue: string;
-  export default tokenValue;
+  interface Token {
+    name: string;
+    value: string | number;
+    var: string;
+  }
+  const token: Token;
+  export default token;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
declare module '@patternfly/react-tokens/dist/esm/*' {
const tokenValue: string;
export default tokenValue;
}
declare module '@patternfly/react-tokens/dist/esm/*' {
interface Token {
name: string;
value: string | number;
var: string;
}
const token: Token;
export default token;
}
🤖 Prompt for AI Agents
In `@types/global.d.ts` around lines 34 - 37, The module declaration for
'@patternfly/react-tokens/dist/esm/*' incorrectly types token exports as plain
strings; update it to export the actual token object shape used across the
codebase (e.g., an interface with properties name: string; value: string |
number; var: string) and change the exported symbol (currently tokenValue) to
that type so imports in components like ToolbarItem.tsx no longer require `as
any` casts; specifically modify the declaration in types/global.d.ts to export
the correct token interface/type for all matching modules.

@khadesamrudhi
Copy link
Author

Hi @thatblindgeye, @mcoker, @kmcfaul

All requested changes have been applied:

  • ToolbarItem widths via setBreakpointCssVars
  • flexGrow via formatBreakpointMods
  • Unrelated files removed
  • Tests updated

Please review again. Thanks!

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.

ToolbarItem - props for width and flex-grow

3 participants