Skip to content

Fix/nextjs hydration errors 12250#12251

Draft
arpanroy41 wants to merge 6 commits intopatternfly:mainfrom
arpanroy41:fix/nextjs-hydration-errors-12250
Draft

Fix/nextjs hydration errors 12250#12251
arpanroy41 wants to merge 6 commits intopatternfly:mainfrom
arpanroy41:fix/nextjs-hydration-errors-12250

Conversation

@arpanroy41
Copy link
Contributor

Replaced the counter-based ID generation with React's useId() hook, which produces deterministic IDs that are consistent between server and client rendering.

New utilities introduced:

  • useSSRSafeId(prefix?) — A hook that wraps React.useId() (React 18+) with an optional prefix. Falls back to a useState-based counter for React 17 compatibility.

  • SSRSafeIds — A render-prop component that exposes useSSRSafeId to class-component patterns, generating both a component ID and an optional OUIA ID.

Refactored utilities:

  • GenerateId — Now delegates to useSSRSafeId internally. API unchanged; isRandom prop is deprecated (no-op).

  • useOUIAId / useOUIAProps — Now use useSSRSafeId for generated OUIA IDs instead of the global counter.

ID format change
Generated IDs change from sequential integers to React useId() tokens:

Before: pf-random-id-0, OUIA-Generated-Tabs-3
After: pf-random-id-:r0:, OUIA-Generated-Tabs-:r1:

This is a non-breaking change — these IDs are auto-generated internals, not user-facing API. Any consumer passing an explicit id prop is unaffected.

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Feb 25, 2026

arpanroy41 and others added 3 commits February 25, 2026 22:12
…ultiple components

- Updated AboutModal, CalendarMonth, CardHeader, Checkbox, DataListCheck, DrawerPanelContent, DualListSelector, DualListSelectorListItem, DualListSelectorListWrapper, DualListSelectorPane, ExpandableSection, FormGroup, InternalFormFieldGroup, JumpLinks, and MenuItem components to use useSSRSafeId for generating unique IDs instead of GenerateId.
- This change improves consistency and simplifies ID generation across components.
…omponents

- Updated Checkbox, ExpandableSection, FormSelect, Menu, MenuToggle, MenuToggleCheckbox, Modal, Nav, NavExpandable, and Progress components to utilize SSRSafeIds for generating unique IDs.
- This change enhances ID management and ensures consistency across components.
The deprecated Table class component in react-table still requires
getDefaultOUIAId which cannot be replaced with hooks. Re-added as
a simplified legacy function marked @deprecated.

Co-authored-by: Cursor <cursoragent@cursor.com>
@arpanroy41 arpanroy41 force-pushed the fix/nextjs-hydration-errors-12250 branch from b69f6fb to b39dbde Compare February 25, 2026 16:46
- improve interface definitions by removing unnecessary line breaks and enhancing readability.
- This change maintains consistency in code style across the codebase.
Reformatted with Prettier 3.8.1 to match CI and updated snapshot
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.

2 participants