Skip to content

Added revalidation of inputs on change.#33

Open
SajidMannikeri17 wants to merge 1 commit into
thunder-id:mainfrom
Infosys:fix/revalidate-on-change
Open

Added revalidation of inputs on change.#33
SajidMannikeri17 wants to merge 1 commit into
thunder-id:mainfrom
Infosys:fix/revalidate-on-change

Conversation

@SajidMannikeri17

@SajidMannikeri17 SajidMannikeri17 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Purpose

Approach

Related Issues

  • N/A

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • New Features
    • Added an option for sign-in, sign-up, and account recovery forms to revalidate fields as users type after leaving the field.
    • Form validation behavior can now be configured independently for each supported form.
    • Existing behavior remains unchanged by default; continuous validation after blur is opt-in.

Signed-off-by: Sajid Mannikeri <sajid.mannikeri@ad.infosys.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Authentication form components now expose revalidateOnChangeAfterBlur. The option defaults to false, flows into useForm, and enables validation on subsequent changes after a field has been touched. Field validation now evaluates the next input value through a shared error computation helper.

Changes

Post-blur validation

Layer / File(s) Summary
Form validation policy
packages/react/src/hooks/useForm.ts
useForm adds the revalidation option, centralizes field error computation, and validates updated values based on change validation and touched-field state.
Authentication component wiring
packages/react/src/components/presentation/auth/{Recovery,SignIn,SignUp}/*
Recovery, sign-in, and sign-up expose the option, default it to false, and pass it into their form configurations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: brionmario

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is just the template with no filled-in Purpose or Approach details, so it does not describe the PR. Fill in the Purpose and Approach sections with the problem, solution, and any behavioral impact, and complete the relevant checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: enabling input revalidation on change.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/react/src/components/presentation/auth/SignIn/BaseSignIn.tsx (1)

591-595: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove hardcoded thunderid literal from data-testid attributes.

As per path instructions, avoid hardcoding the vendor name thunderid in DOM data-* attributes. Since this is an internal test identifier and the brand prefix is likely not load-bearing, the best fix is to avoid the vendor prefix entirely and use data-testid="signin". If a brand-scoped namespace is genuinely required by external testing frameworks, use ${getVendorPrefix(vendor)}-signin instead.

  • packages/react/src/components/presentation/auth/SignIn/BaseSignIn.tsx#L591-L595: replace data-testid="thunderid-signin" with data-testid="signin".
  • packages/react/src/components/presentation/auth/SignIn/BaseSignIn.tsx#L601-L606: replace data-testid="thunderid-signin" with data-testid="signin".
  • packages/react/src/components/presentation/auth/SignIn/BaseSignIn.tsx#L618-L623: replace data-testid="thunderid-signin" with data-testid="signin".
  • packages/react/src/components/presentation/auth/SignIn/BaseSignIn.tsx#L634-L639: replace data-testid="thunderid-signin" with data-testid="signin".
🤖 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/src/components/presentation/auth/SignIn/BaseSignIn.tsx` around
lines 591 - 595, Remove the hardcoded vendor prefix from all four data-testid
attributes in BaseSignIn:
packages/react/src/components/presentation/auth/SignIn/BaseSignIn.tsx at lines
591-595, 601-606, 618-623, and 634-639. Set each identifier to the unprefixed
signin value; no other rendering behavior needs to change.

Source: Path instructions

🧹 Nitpick comments (1)
packages/react/src/hooks/useForm.ts (1)

320-329: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Prevent unnecessary state updates when the field error remains unchanged.

When shouldValidate is true, setFormErrors currently creates and returns a new object on every keystroke, even if the error for the field hasn't changed. Returning the existing state object when there's no change allows React to bail out of unnecessary re-renders.

♻️ Proposed refactor to bail out of state updates
       const error: string | null = computeFieldError(value, getFieldConfig(name), requiredMessage);
       setFormErrors((prev: Record<keyof T, string>) => {
+        if (prev[name] === error || (!error && !(name in prev))) {
+          return prev;
+        }
         const newErrors: Record<keyof T, string> = {...prev};
         if (error) {
           newErrors[name] = error;
🤖 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/src/hooks/useForm.ts` around lines 320 - 329, Update the
setFormErrors callback in the shouldValidate path to compare the current error
for name with the newly computed error before cloning state. Return the existing
prev object when the field’s error is unchanged; otherwise preserve the current
add/remove behavior using a copied error map.
🤖 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.

Outside diff comments:
In `@packages/react/src/components/presentation/auth/SignIn/BaseSignIn.tsx`:
- Around line 591-595: Remove the hardcoded vendor prefix from all four
data-testid attributes in BaseSignIn:
packages/react/src/components/presentation/auth/SignIn/BaseSignIn.tsx at lines
591-595, 601-606, 618-623, and 634-639. Set each identifier to the unprefixed
signin value; no other rendering behavior needs to change.

---

Nitpick comments:
In `@packages/react/src/hooks/useForm.ts`:
- Around line 320-329: Update the setFormErrors callback in the shouldValidate
path to compare the current error for name with the newly computed error before
cloning state. Return the existing prev object when the field’s error is
unchanged; otherwise preserve the current add/remove behavior using a copied
error map.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 50a0fcd0-cae2-4355-8cd9-b32884e12d2a

📥 Commits

Reviewing files that changed from the base of the PR and between a02382f and 3617dcf.

📒 Files selected for processing (5)
  • packages/react/src/components/presentation/auth/Recovery/BaseRecovery.tsx
  • packages/react/src/components/presentation/auth/SignIn/BaseSignIn.tsx
  • packages/react/src/components/presentation/auth/SignIn/SignIn.tsx
  • packages/react/src/components/presentation/auth/SignUp/BaseSignUp.tsx
  • packages/react/src/hooks/useForm.ts

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.

1 participant