Skip to content

chore(Form/FormGroup): Include OUIAProps for Form and FormGroup#12426

Open
mshriver wants to merge 2 commits into
patternfly:mainfrom
mshriver:form-ouia
Open

chore(Form/FormGroup): Include OUIAProps for Form and FormGroup#12426
mshriver wants to merge 2 commits into
patternfly:mainfrom
mshriver:form-ouia

Conversation

@mshriver
Copy link
Copy Markdown

@mshriver mshriver commented May 14, 2026

What:

Add OUIAProps support to Form and FormGroup, for better test automation support.

First contribution, believe I've followed contributing guidelines.
Opus/Sonnet used for initial commit and mentioned as co-author.

Tear it up! Thanks for review and consideration.

Summary by CodeRabbit

  • New Features

    • Form and FormGroup now accept optional OUIA properties: ouiaId (number|string) and ouiaSafe (boolean).
    • These OUIA attributes are applied to the rendered components to improve automated UI identification; ouiaSafe defaults to true.
  • Documentation

    • OUIA docs updated to include Form and FormGroup in the list of OUIA-compliant components.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Review Change Stack

Walkthrough

This PR adds OUIA support to Form and FormGroup: both components accept optional ouiaId and ouiaSafe props, apply attributes from useOUIAProps to their root elements, and documentation is updated to list them as OUIA-compliant.

Changes

OUIA Support for Form Components

Layer / File(s) Summary
Form component OUIA integration
packages/react-core/src/components/Form/Form.tsx
FormProps now includes optional ouiaId and ouiaSafe. FormBase refactored to destructure OUIA props, call useOUIAProps(Form.displayName, ouiaId, ouiaSafe), and spread resulting ouiaProps onto the <form> element alongside existing props and styling.
FormGroup component OUIA integration
packages/react-core/src/components/Form/FormGroup.tsx
FormGroupProps now includes optional ouiaId and ouiaSafe (component defaults ouiaSafe = true). FormGroup computes ouiaProps via useOUIAProps and spreads them onto the root <div>.
OUIA documentation update
packages/react-core/src/helpers/OUIA/OUIA.md
Added Form and FormGroup entries to the react-core OUIA-compliant components list.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding OUIAProps support to Form and FormGroup components, which matches the changeset's focus on integrating OUIA support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown
Collaborator

patternfly-build commented May 14, 2026

@mshriver mshriver marked this pull request as ready for review May 14, 2026 11:25
Copilot AI review requested due to automatic review settings May 14, 2026 11:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Open UI Automation (OUIA) attribute support to the Form and FormGroup components in react-core to improve automated testability, and updates related documentation/tests to reflect the new attributes.

Changes:

  • Add OUIAProps support and useOUIAProps integration to Form and FormGroup.
  • Update OUIA documentation list to include Form and FormGroup.
  • Update relevant Jest snapshots to include the new data-ouia-* attributes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/react-core/src/helpers/OUIA/OUIA.md Adds Form and FormGroup to the documented list of OUIA-compliant components.
packages/react-core/src/components/Form/Form.tsx Implements OUIA props on the <form> root element.
packages/react-core/src/components/Form/FormGroup.tsx Implements OUIA props on the FormGroup root <div>.
packages/react-core/src/components/LoginPage/tests/snapshots/LoginForm.test.tsx.snap Updates snapshots to include OUIA attributes emitted by Form/FormGroup (and resulting generated IDs).
packages/react-core/src/components/Form/tests/snapshots/Form.test.tsx.snap Updates Form snapshots for new OUIA attributes.
packages/react-core/src/components/Form/tests/snapshots/FormGroup.test.tsx.snap Updates FormGroup snapshots for new OUIA attributes (and nested Form usage in some cases).
packages/react-core/src/components/Form/tests/snapshots/ActionGroup.test.tsx.snap Updates snapshot due to Form now emitting OUIA attributes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +47
[cssMaxWidth.name]: maxWidth,
...props.style
} as React.CSSProperties
})}
{...props}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is true for the main branch and I'd rather not include this change to the props processing behavior in this PR

@mshriver mshriver changed the title Include OUIAProps for Form and FormGroup chore: Include OUIAProps for Form and FormGroup May 14, 2026
@mshriver mshriver changed the title chore: Include OUIAProps for Form and FormGroup chore(Form/FormGroup): Include OUIAProps for Form and FormGroup May 14, 2026
mshriver and others added 2 commits June 1, 2026 08:47
Co-authored-by: Claude <noreply@anthropic.com>
Includes Form and FormGroup

ActionGroup and LoginForm too, as they use Forms
Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
packages/react-core/src/components/Form/Form.tsx (1)

37-37: ⚡ Quick win

Consider adding OUIA test coverage for Form.

New OUIA-enabled components in this repo typically ship with tests asserting the data-ouia-component-type/data-ouia-component-id/data-ouia-safe attributes (e.g. honoring a passed ouiaId and the ouiaSafe default). Adding one would lock in the contract.

Want me to draft a test for the OUIA attributes on Form?

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/react-core/src/components/Form/Form.tsx` at line 37, Add a unit test
for the Form component to assert it renders OUIA attributes from useOUIAProps:
render/mount Form (import Form from Form.tsx) with a specific ouiaId prop and
without passing ouiaSafe, then assert the rendered root element has
data-ouia-component-type equal to Form.displayName (or "Form"),
data-ouia-component-id equal to the passed ouiaId, and data-ouia-safe equals the
default value; also add a second assertion toggling ouiaSafe to false to confirm
it changes. Use the existing test utilities (e.g., render from
`@testing-library/react` or the repo's test helpers) and reference Form and
useOUIAProps in the test description so the contract is covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/react-core/src/components/Form/Form.tsx`:
- Line 37: Add a unit test for the Form component to assert it renders OUIA
attributes from useOUIAProps: render/mount Form (import Form from Form.tsx) with
a specific ouiaId prop and without passing ouiaSafe, then assert the rendered
root element has data-ouia-component-type equal to Form.displayName (or "Form"),
data-ouia-component-id equal to the passed ouiaId, and data-ouia-safe equals the
default value; also add a second assertion toggling ouiaSafe to false to confirm
it changes. Use the existing test utilities (e.g., render from
`@testing-library/react` or the repo's test helpers) and reference Form and
useOUIAProps in the test description so the contract is covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0568f90c-3312-4d61-8da0-c82a02a567f8

📥 Commits

Reviewing files that changed from the base of the PR and between 8ebdf29 and 5c07b8b.

⛔ Files ignored due to path filters (4)
  • packages/react-core/src/components/Form/__tests__/__snapshots__/ActionGroup.test.tsx.snap is excluded by !**/*.snap
  • packages/react-core/src/components/Form/__tests__/__snapshots__/Form.test.tsx.snap is excluded by !**/*.snap
  • packages/react-core/src/components/Form/__tests__/__snapshots__/FormGroup.test.tsx.snap is excluded by !**/*.snap
  • packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginForm.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • packages/react-core/src/components/Form/Form.tsx
  • packages/react-core/src/components/Form/FormGroup.tsx
  • packages/react-core/src/helpers/OUIA/OUIA.md
✅ Files skipped from review due to trivial changes (1)
  • packages/react-core/src/helpers/OUIA/OUIA.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react-core/src/components/Form/FormGroup.tsx

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.

3 participants