Skip to content

chore(TextInputGroup): Added default as an option for validated#12349

Open
tlabaj wants to merge 1 commit intopatternfly:mainfrom
tlabaj:textinputgroup
Open

chore(TextInputGroup): Added default as an option for validated#12349
tlabaj wants to merge 1 commit intopatternfly:mainfrom
tlabaj:textinputgroup

Conversation

@tlabaj
Copy link
Copy Markdown
Contributor

@tlabaj tlabaj commented Apr 10, 2026

What: Closes #11834

Extends TextInputGroup validation so it aligns with TextInput, FormSelect, and related controls. Consumers can set validated="default" or ValidatedOptions.default to clear success/warning/error styling after a prior validation state.

TextInputGroup

  • validated type is now 'success' | 'warning' | 'error' | 'default' | ValidatedOptions (string literals plus enum, similar to NumberInput).
  • JSDoc describes the validation states and that default clears validation styling.
  • Modifier classes apply only when ['success', 'error', 'warning'].includes(validated), so default does not add success/warning/error modifiers.
  • ValidatedOptions is imported from helpers/constants, consistent with TextInput / FormSelect.

TextInputGroupMain

  • Status icon renders only for success, warning, and error (hasStatusIcon), so default does not show a status icon.
  • Icon selection uses straightforward if branches (no nested ternaries) and statusIcons.danger / .success / .warning for correct TypeScript typing.

Tests

  • No validation modifiers on the group when validated="default".
  • No status icon when context provides validated: 'default'.

API impact

  • Backward compatible for existing success / warning / error usage; the prop type is widened, not narrowed.

Summary by CodeRabbit

  • New Features

    • Added support for a default validation state in the TextInputGroup component, allowing neutral styling without validation indicators.
  • Documentation

    • Updated component example documentation to include additional variant references.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Walkthrough

Added support for a default validation state to the TextInputGroup component. The validated prop now accepts default and ValidatedOptions type. Validation styling is conditionally applied only when validated is success, warning, or error, not when set to default. Updated tests verify the absence of validation modifiers and status icons in the default state. Documentation metadata was also extended for the Content component examples.

Changes

Cohort / File(s) Summary
TextInputGroup Implementation
packages/react-core/src/components/TextInputGroup/TextInputGroup.tsx, packages/react-core/src/components/TextInputGroup/TextInputGroupMain.tsx
Added default value support to validated prop type. Introduced hasValidatedModifier boolean to gate CSS modifier application and hasStatusIcon boolean to gate status icon rendering, ensuring modifiers and icons only apply for success, warning, or error states.
TextInputGroup Tests
packages/react-core/src/components/TextInputGroup/__tests__/TextInputGroup.test.tsx, packages/react-core/src/components/TextInputGroup/__tests__/TextInputGroupMain.test.tsx
Added test cases verifying that validated="default" suppresses validation modifier classes and prevents status icon rendering.
Documentation
packages/react-core/src/components/Content/examples/Content.md
Extended propComponents metadata to include ContentVariants component association.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The documentation update to Content.md appears to be unrelated to the TextInputGroup validation changes and may be out of scope. Clarify whether the Content.md documentation change is intentional; if unrelated to issue #11834, remove it to keep the PR focused on TextInputGroup validation.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding 'default' as a validation option for TextInputGroup's validated prop.
Linked Issues check ✅ Passed All requirements from issue #11834 are met: 'default' option added to ValidatedOptions, validation styling is removed when default is set, and the implementation allows consumers to clear validation state.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 Apr 10, 2026

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/TextInputGroup/TextInputGroup.tsx (1)

39-49: Consider centralizing the status-capable validation states.

The same ['success', 'error', 'warning'] source of truth now exists here and again in packages/react-core/src/components/TextInputGroup/TextInputGroupMain.tsx Line 89. Pulling that into a shared helper/constant would make the next validation-state change less likely to desync styling and icon behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-core/src/components/TextInputGroup/TextInputGroup.tsx` around
lines 39 - 49, The list of validation states is duplicated; extract the array
['success','error','warning'] into a shared constant (e.g., VALIDATED_STATES)
exported from a new or existing shared module and replace the inline arrays in
TextInputGroup (used by hasValidatedModifier) and TextInputGroupMain (the usage
at Line 89) to import and reference VALIDATED_STATES; update
hasValidatedModifier to compute const hasValidatedModifier =
VALIDATED_STATES.includes(validated) and ensure any type casts or keyof
narrowing still work with the shared constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/react-core/src/components/TextInputGroup/TextInputGroup.tsx`:
- Around line 39-49: The list of validation states is duplicated; extract the
array ['success','error','warning'] into a shared constant (e.g.,
VALIDATED_STATES) exported from a new or existing shared module and replace the
inline arrays in TextInputGroup (used by hasValidatedModifier) and
TextInputGroupMain (the usage at Line 89) to import and reference
VALIDATED_STATES; update hasValidatedModifier to compute const
hasValidatedModifier = VALIDATED_STATES.includes(validated) and ensure any type
casts or keyof narrowing still work with the shared constant.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c04c5327-b4c5-4f1a-bf77-fbc3967a3f79

📥 Commits

Reviewing files that changed from the base of the PR and between 911223a and 9ce7457.

📒 Files selected for processing (5)
  • packages/react-core/src/components/Content/examples/Content.md
  • packages/react-core/src/components/TextInputGroup/TextInputGroup.tsx
  • packages/react-core/src/components/TextInputGroup/TextInputGroupMain.tsx
  • packages/react-core/src/components/TextInputGroup/__tests__/TextInputGroup.test.tsx
  • packages/react-core/src/components/TextInputGroup/__tests__/TextInputGroupMain.test.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.

TextInputGroup

2 participants