Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run lint:*)"
]
}
}
78 changes: 74 additions & 4 deletions packages/react-core/src/components/Toolbar/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import styles from '@patternfly/react-styles/css/components/Toolbar/toolbar';
import { GenerateId } from '../../helpers/GenerateId/GenerateId';
import { css } from '@patternfly/react-styles';
import { ToolbarContext } from './ToolbarUtils';
import { ToolbarContext, globalBreakpoints, containerBreakpoints } from './ToolbarUtils';
import { ToolbarLabelGroupContent } from './ToolbarLabelGroupContent';
import { formatBreakpointMods, canUseDOM } from '../../helpers/util';
import { getDefaultOUIAId, getOUIAProps, OUIAProps } from '../../helpers';
import { PageContext } from '../Page/PageContext';
import { getResizeObserver } from '../../helpers/resizeObserver';

export enum ToolbarColorVariant {
default = 'default',
Expand Down Expand Up @@ -59,6 +60,10 @@
colorVariant?: ToolbarColorVariant | 'default' | 'no-background' | 'primary' | 'secondary';
/** Flag indicating the toolbar padding is removed */
hasNoPadding?: boolean;
/** Use container queries instead of viewport media queries for responsive behavior */
useContainerQuery?: boolean;
/** Breakpoint for container queries. Only applies when useContainerQuery is true. */
containerQueryBreakpoint?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';
}

export interface ToolbarState {
Expand All @@ -69,6 +74,8 @@
filterInfo: FilterInfo;
/** Used to keep track of window width so we can collapse expanded content when window is resizing */
windowWidth: number;
/** Used to keep track of container width so we can collapse expanded content when container is resizing */
containerWidth: number;
ouiaStateId: string;
}

Expand All @@ -79,12 +86,15 @@
class Toolbar extends Component<ToolbarProps, ToolbarState> {
static displayName = 'Toolbar';
labelGroupContentRef = createRef<HTMLDivElement>();
toolbarRef = createRef<HTMLDivElement>();
observer: any = () => {};
staticFilterInfo = {};
hasNoPadding = false;
state = {
isManagedToggleExpanded: false,
filterInfo: {},
windowWidth: canUseDOM ? window.innerWidth : 1200,
containerWidth: 0,
ouiaStateId: getDefaultOUIAId(Toolbar.displayName)
};

Expand All @@ -105,15 +115,58 @@
}
};

closeExpandableContentOnContainerResize = () => {
if (this.toolbarRef.current && this.toolbarRef.current.clientWidth) {
const newWidth = this.toolbarRef.current.clientWidth;

if (newWidth !== this.state.containerWidth) {
// If expanded and container is wide enough for inline display at the specific breakpoint, close it
const specificBreakpoint = this.props.containerQueryBreakpoint || 'lg';

// Use container breakpoints when using container queries, otherwise use global breakpoints
let isWideEnoughForInline: boolean;
if (this.props.useContainerQuery) {
// Handle 'sm' case for container breakpoints
const breakpointKey = specificBreakpoint === 'sm' ? 'sm' : specificBreakpoint;
isWideEnoughForInline = newWidth >= containerBreakpoints[breakpointKey];
} else {
// Handle 'sm' case - map to 'md' since globalBreakpoints doesn't have 'sm'
const breakpointKey = specificBreakpoint === 'sm' ? 'md' : specificBreakpoint;
isWideEnoughForInline = newWidth >= globalBreakpoints[breakpointKey];
}

if (this.state.isManagedToggleExpanded && isWideEnoughForInline) {
this.setState(() => ({
isManagedToggleExpanded: false,
containerWidth: newWidth
}));
} else {
// Just update width without closing
this.setState(() => ({
containerWidth: newWidth
}));
}
}
}
};

componentDidMount() {
if (this.isToggleManaged() && canUseDOM) {
window.addEventListener('resize', this.closeExpandableContent);
if (this.props.useContainerQuery && this.toolbarRef.current) {
this.observer = getResizeObserver(this.toolbarRef.current, this.closeExpandableContentOnContainerResize, true);
} else {
window.addEventListener('resize', this.closeExpandableContent);
}
}
}

componentWillUnmount() {
if (this.isToggleManaged() && canUseDOM) {
window.removeEventListener('resize', this.closeExpandableContent);
if (this.props.useContainerQuery) {
this.observer();
} else {
window.removeEventListener('resize', this.closeExpandableContent);
}
}
}

Expand Down Expand Up @@ -147,6 +200,8 @@
numberOfFiltersText,
customLabelGroupContent,
colorVariant = ToolbarColorVariant.default,
useContainerQuery,
containerQueryBreakpoint,
...props
} = this.props;

Expand All @@ -167,13 +222,27 @@
isFullHeight && styles.modifiers.fullHeight,
isStatic && styles.modifiers.static,
isSticky && styles.modifiers.sticky,
useContainerQuery && !containerQueryBreakpoint && styles.modifiers.container,

Check failure on line 225 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build, test & deploy

Property 'container' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.

Check failure on line 225 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build

Property 'container' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.
useContainerQuery &&
containerQueryBreakpoint &&
((): string => {
const breakpointClassMap: Record<string, string> = {
'2xl': styles.modifiers.container_2xl,

Check failure on line 230 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build, test & deploy

Property 'container_2xl' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.

Check failure on line 230 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build

Property 'container_2xl' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.
sm: styles.modifiers.containerSm,

Check failure on line 231 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build, test & deploy

Property 'containerSm' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.

Check failure on line 231 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build

Property 'containerSm' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.
md: styles.modifiers.containerMd,

Check failure on line 232 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build, test & deploy

Property 'containerMd' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.

Check failure on line 232 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build

Property 'containerMd' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.
lg: styles.modifiers.containerLg,

Check failure on line 233 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build, test & deploy

Property 'containerLg' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.

Check failure on line 233 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build

Property 'containerLg' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.
xl: styles.modifiers.containerXl

Check failure on line 234 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build, test & deploy

Property 'containerXl' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.

Check failure on line 234 in packages/react-core/src/components/Toolbar/Toolbar.tsx

View workflow job for this annotation

GitHub Actions / Build

Property 'containerXl' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.
};
return breakpointClassMap[containerQueryBreakpoint] || '';
})(),
Comment on lines +225 to +237
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

Build failure: CSS modifier classes don't exist yet.

The TypeScript build fails because styles.modifiers.container, styles.modifiers.containerSm, etc. don't exist in the current @patternfly/react-styles package. This PR depends on patternfly/patternfly#8025 for these CSS classes.

Consider one of:

  1. Wait for the core PR to merge and release before this PR
  2. Add type assertions to suppress errors temporarily (not recommended)
  3. Use string literals for class names until the styles package is updated
-              useContainerQuery && !containerQueryBreakpoint && styles.modifiers.container,
-              useContainerQuery &&
-                containerQueryBreakpoint &&
-                ((): string => {
-                  const breakpointClassMap: Record<string, string> = {
-                    '2xl': styles.modifiers.container_2xl,
-                    sm: styles.modifiers.containerSm,
-                    md: styles.modifiers.containerMd,
-                    lg: styles.modifiers.containerLg,
-                    xl: styles.modifiers.containerXl
-                  };
-                  return breakpointClassMap[containerQueryBreakpoint] || '';
-                })(),
+              useContainerQuery && !containerQueryBreakpoint && 'pf-m-container',
+              useContainerQuery &&
+                containerQueryBreakpoint &&
+                `pf-m-container-${containerQueryBreakpoint}`,

Note: The above is a workaround. The proper fix is to coordinate with the core PatternFly release.

📝 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
useContainerQuery && !containerQueryBreakpoint && styles.modifiers.container,
useContainerQuery &&
containerQueryBreakpoint &&
((): string => {
const breakpointClassMap: Record<string, string> = {
'2xl': styles.modifiers.container_2xl,
sm: styles.modifiers.containerSm,
md: styles.modifiers.containerMd,
lg: styles.modifiers.containerLg,
xl: styles.modifiers.containerXl
};
return breakpointClassMap[containerQueryBreakpoint] || '';
})(),
useContainerQuery && !containerQueryBreakpoint && 'pf-m-container',
useContainerQuery &&
containerQueryBreakpoint &&
`pf-m-container-${containerQueryBreakpoint}`,
🧰 Tools
🪛 GitHub Actions: Documentation

[error] 225-225: TS2339: Property 'container' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.

🪛 GitHub Check: Build, test & deploy

[failure] 234-234:
Property 'containerXl' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.


[failure] 233-233:
Property 'containerLg' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.


[failure] 232-232:
Property 'containerMd' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.


[failure] 231-231:
Property 'containerSm' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.


[failure] 230-230:
Property 'container_2xl' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.


[failure] 225-225:
Property 'container' does not exist on type '{ hidden: "pf-m-hidden"; hiddenOnSm: "pf-m-hidden-on-sm"; visibleOnSm: "pf-m-visible-on-sm"; hiddenOnMd: "pf-m-hidden-on-md"; visibleOnMd: "pf-m-visible-on-md"; hiddenOnLg: "pf-m-hidden-on-lg"; ... 346 more ...; hideOn_2xl: "pf-m-hide-on-2xl"; }'.

🤖 Prompt for AI Agents
packages/react-core/src/components/Toolbar/Toolbar.tsx around lines 225 to 237:
the code currently references non‑existent properties on styles.modifiers
(container, containerSm, containerMd, containerLg, containerXl, container_2xl)
which breaks the TypeScript build; replace those property accesses with explicit
string literal class names (use the class names added by
patternfly/patternfly#8025 as the fallback values) or guard with a fallback
string (e.g., styles.modifiers?.container || 'pf-c-toolbar__container') so
builds succeed until the core package is released, and add a TODO comment to
revert to styles.modifiers.* once the patternfly release is available
(alternatively delay merge or use a narrow type assertion if you prefer).

formatBreakpointMods(inset, styles, '', getBreakpoint(width)),
colorVariant === 'primary' && styles.modifiers.primary,
colorVariant === 'secondary' && styles.modifiers.secondary,
colorVariant === 'no-background' && styles.modifiers.noBackground,
className
)}
id={randomId}
ref={this.toolbarRef}
{...getOUIAProps(Toolbar.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId)}
{...props}
>
Expand All @@ -188,7 +257,8 @@
clearFiltersButtonText,
showClearFiltersButton,
toolbarId: randomId,
customLabelGroupContent
customLabelGroupContent,
useContainerQuery
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class ToolbarToggleGroup extends Component<ToolbarToggleGroupProps> {
<PageContext.Consumer>
{({ width, getBreakpoint }) => (
<ToolbarContext.Consumer>
{({ toggleIsExpanded: managedOnToggle }) => {
{({ toggleIsExpanded: managedOnToggle, useContainerQuery }) => {
const _onToggle = onToggle !== undefined ? onToggle : managedOnToggle;

return (
Expand Down Expand Up @@ -260,7 +260,12 @@ class ToolbarToggleGroup extends Component<ToolbarToggleGroupProps> {
| 'actionGroupPlain'
| 'labelGroup'
],
formatBreakpointMods(breakpointMod, styles, '', getBreakpoint(width)),
formatBreakpointMods(
breakpointMod,
styles,
'',
useContainerQuery ? undefined : getBreakpoint(width)
),
formatBreakpointMods(visibility, styles, '', getBreakpoint(width)),
formatBreakpointMods(gap, styles, '', getBreakpoint(width)),
formatBreakpointMods(columnGap, styles, '', getBreakpoint(width)),
Expand Down
13 changes: 12 additions & 1 deletion packages/react-core/src/components/Toolbar/ToolbarUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ToolbarContextProps {
showClearFiltersButton?: boolean;
toolbarId?: string;
customLabelGroupContent?: React.ReactNode;
useContainerQuery?: boolean;
}

export const ToolbarContext = createContext<ToolbarContextProps>({
Expand All @@ -23,7 +24,8 @@ export const ToolbarContext = createContext<ToolbarContextProps>({
labelGroupContentRef: null,
updateNumberFilters: () => {},
numberOfFilters: 0,
clearAllFilters: () => {}
clearAllFilters: () => {},
useContainerQuery: false
});

interface ToolbarContentContextProps {
Expand All @@ -49,3 +51,12 @@ export const globalBreakpoints = {
xl: parseInt(globalBreakpointXl.value) * 16,
'2xl': parseInt(globalBreakpoint2xl.value) * 16
};

// Container query breakpoints match CSS container query values
export const containerBreakpoints = {
sm: 286,
md: 478,
lg: 702,
xl: 992, // You may need to verify this value
'2xl': 1200 // You may need to verify this value
};
Comment on lines +55 to +62
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

🌐 Web query:

PatternFly container query breakpoints CSS values @container

💡 Result:

PatternFly’s standard breakpoint sizes (exposed as CSS variables) are:

  • sm: 36rem — 576px. [--pf-global--breakpoint--sm]. [1]
  • md: 48rem — 768px. [--pf-global--breakpoint--md]. [1]
  • lg: 62rem — 992px. [--pf-global--breakpoint--lg]. [1]
  • xl: 75rem — 1200px. [--pf-global--breakpoint--xl]. [1]
  • 2xl: 90.625rem — 1450px. [--pf-global--breakpoint--2xl]. [1]

You can use those values in container queries (or media/container-query CSS) directly or via the PatternFly CSS custom properties. Example usages:

  • @container (min-width: 36rem) { /* sm and up relative to container */ } [1]
  • @container (min-width: var(--pf-global--breakpoint--lg)) { /* lg and up */ } [2]

Sources: PatternFly development guidelines (breakpoint values) and PatternFly global CSS variables. [1][2]

References
[1] PatternFly development guidelines — breakpoint values.
[2] PatternFly global CSS variables (variable names such as --pf-global--breakpoint--[breakpoint]).


🏁 Script executed:

# Search for references to containerBreakpoints and context about these values
rg "containerBreakpoints|container.*breakpoint" packages/react-core/src/components/Toolbar/ -A 3 -B 3

# Also check if there are comments or documentation explaining the choice
rg "286|478|702" packages/ -B 2 -A 2

# Search for any related issue references or PR descriptions
rg "8025|container.*query" packages/react-core/src/components/Toolbar/ -B 2 -A 2

Repository: patternfly/patternfly-react

Length of output: 50384


🏁 Script executed:

# Search for CSS container query definitions or related documentation
fd -e css -e scss | xargs rg -l "container.*query|@container" 2>/dev/null | head -10

# Look for any tests or examples that might validate these breakpoint values
fd -e test.tsx -e spec.tsx | xargs rg "containerBreakpoints|286|478|702" 2>/dev/null | head -20

# Check if there's any documentation about these values
fd -e md | xargs rg "container.*breakpoint|286|478|702" 2>/dev/null

Repository: patternfly/patternfly-react

Length of output: 21022


Remove unverified comments from hardcoded breakpoint values or verify them against the CSS container query definitions.

The hardcoded containerBreakpoints values (sm: 286, md: 478, lg: 702, xl: 992, 2xl: 1200) do not match PatternFly's standard global breakpoints (sm: 576px, md: 768px, lg: 992px, xl: 1200px, 2xl: 1450px). While these custom values appear intentional for container-based layout, the comments flagging xl and 2xl as needing verification indicate uncertainty. Either remove the comments if these values are confirmed, or provide a reference to the CSS @container definitions from the PatternFly core CSS that validates them.

🤖 Prompt for AI Agents
In packages/react-core/src/components/Toolbar/ToolbarUtils.tsx around lines 55
to 62, the hardcoded containerBreakpoints include unverified inline comments for
xl and 2xl and contain values that don't match PatternFly global breakpoints;
either remove the “You may need to verify this value” comments if these numbers
are intentionally correct, or verify and update the breakpoint numbers to match
the CSS @container definitions (or PatternFly globals) and add a short code
comment referencing the exact CSS file and selector/variable (e.g., core CSS
file and @container rules) used to derive the values so future reviewers can
confirm them.

11 changes: 11 additions & 0 deletions packages/react-core/src/components/Toolbar/examples/Toolbar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.ws-react-c-toolbar-resize-container {
resize: horizontal;
overflow: auto;
border: var(--pf-t--global--border--width--extra-strong) dashed var(--pf-t--global--border--color--default);
/* padding: var(--pf-t--global--spacer--md); */
width: 800px;
min-width: 300px;
max-width: 100%;
height: 15em;
}

Comment on lines +1 to +11
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

Consolidate duplicate CSS files.

This file is identical to packages/react-core/src/demos/examples/Toolbar/Toolbar.css. Having two identical CSS files creates maintenance overhead and risks divergence. Consider:

  • Keeping one canonical version in a shared location
  • Importing it from both demos and examples
  • Or documenting why both copies are necessary
🤖 Prompt for AI Agents
packages/react-core/src/components/Toolbar/examples/Toolbar.css lines 1-11: this
CSS is duplicated in packages/react-core/src/demos/examples/Toolbar/Toolbar.css;
remove the duplicate and pick one canonical location (prefer the demos or a new
shared styles folder), update both demo and example imports to reference that
single file (or re-export it from a shared module), delete the redundant file,
and verify build imports/paths and any package exports so nothing breaks; if
both must remain temporarily, add a TODO comment pointing to the canonical file
and include a follow-up ticket.

21 changes: 21 additions & 0 deletions packages/react-core/src/components/Toolbar/examples/Toolbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ propComponents: ['Toolbar', 'ToolbarContent', 'ToolbarGroup', 'ToolbarItem', 'To
section: components
---

import './Toolbar.css';
import { Fragment, useState } from 'react';

import EditIcon from '@patternfly/react-icons/dist/esm/icons/edit-icon';
Expand Down Expand Up @@ -113,6 +114,26 @@ When all of a toolbar's required elements cannot fit in a single line, you can s

```

## Examples with container queries

Container queries allow the toolbar to respond to its container size rather than the viewport size. This is useful when toolbars appear in sidebars, cards, modals, or other constrained spaces where you want the toolbar to adapt to its container's width independently from the viewport.

### Basic container query usage

The toolbar adapts based on its container width instead of the viewport width. Resize the container to see the responsive behavior.

```ts file="./ToolbarContainerQueryBasic.tsx"

```

### Container query breakpoints

Use `containerQueryBreakpoint` to collapse the toolbar at different container widths.

```ts file="./ToolbarContainerQueryBreakpoints.tsx"

```

## Examples with spacers and wrapping
You may adjust the space between toolbar items to arrange them into groups. Read our spacers documentation to learn more about using spacers.

Expand Down
Loading
Loading