[Bug-fix] Improve i18n for input error messages - #4266
Conversation
📝 WalkthroughWalkthroughChangesEmail validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant User
participant SignInBox
participant FlowComponentRenderer
User->>SignInBox: Submit email input
SignInBox->>SignInBox: Validate required and email format
SignInBox->>FlowComponentRenderer: Pass errors and touched state
FlowComponentRenderer-->>User: Display validation result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/apps/gate/src/components/SignIn/__tests__/SignInBox.test.tsx (1)
1999-2355: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting a shared fixture builder for the repeated
EMAIL_INPUTcomponent array.Nine tests redeclare a near-identical ~25-line
componentsarray (BLOCK > EMAIL_INPUT + submit ACTION), differing only byrequiredor the typed value. A small helper likebuildEmailInputComponents({required})would cut duplication and make future edits (e.g., adding a new field) less error-prone.🤖 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 `@frontend/apps/gate/src/components/SignIn/__tests__/SignInBox.test.tsx` around lines 1999 - 2355, The repeated BLOCK > EMAIL_INPUT plus submit ACTION fixture across the EMAIL_INPUT tests should be centralized. Add a shared builder such as buildEmailInputComponents accepting the required setting, replace each duplicated components array with the builder, and preserve each test’s existing required behavior and other component properties.
🤖 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.
Inline comments:
In `@frontend/apps/gate/src/components/SignIn/SignInBox.tsx`:
- Around line 61-63: Update the required-field validation message in the
component validation block to provide fallback default strings for both the
outer validation-key t() call and the nested field-label t() call, matching the
fallback pattern used by the email-invalid message below. Preserve the existing
translated values when available while ensuring unresolved keys produce
user-facing text.
---
Nitpick comments:
In `@frontend/apps/gate/src/components/SignIn/__tests__/SignInBox.test.tsx`:
- Around line 1999-2355: The repeated BLOCK > EMAIL_INPUT plus submit ACTION
fixture across the EMAIL_INPUT tests should be centralized. Add a shared builder
such as buildEmailInputComponents accepting the required setting, replace each
duplicated components array with the builder, and preserve each test’s existing
required behavior and other component properties.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: af076f31-8ca4-416c-9da5-0cb8c318f861
📒 Files selected for processing (3)
frontend/apps/gate/src/components/SignIn/SignInBox.tsxfrontend/apps/gate/src/components/SignIn/__tests__/SignInBox.test.tsxfrontend/packages/i18n/src/locales/en-US.ts
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
8f73555 to
e5da69e
Compare
e5da69e to
ea71be2
Compare
b1ae2f3 to
bc63d61
Compare
736fcae to
208d51c
Compare
| if (!component) return; | ||
|
|
||
| let error = ''; | ||
| if (component.type === 'EMAIL_INPUT' && value.trim() && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) { |
There was a problem hiding this comment.
This regex is repeated in multiple places. Better if we can keep a single definition and reuse it
There was a problem hiding this comment.
Added the regex to utils and updated to be reused.
| <Alert severity="error" sx={{mb: 2}}> | ||
| <AlertTitle>{t('signup:errors.signup.failed.message')}</AlertTitle> | ||
| {error.message ?? t('signup:errors.signup.failed.description')} | ||
| <AlertTitle>{t("Oops, that didn't work")}</AlertTitle> |
There was a problem hiding this comment.
Shouldn't we keep i18n keys too? Use fixed text as the fallback only
There was a problem hiding this comment.
reverted the change
| // ============================================================================ | ||
| validations: { | ||
| 'form.field.required': '{{field}} is required.', | ||
| 'field.email.invalid': 'Please enter a valid email address.', |
There was a problem hiding this comment.
Hope we have added all i18n keys or other translations already exists
There was a problem hiding this comment.
Added the i18n keys provided returned by input validator
a0fa51e to
6035eaa
Compare
6035eaa to
f46bf4d
Compare
f46bf4d to
316c585
Compare
Purpose
Fixes: #3994
Approach
Key changes
onBlurcallback prop through the component chain (FlowComponentRendererProps→FlowFieldProps→BlockAdapter→StackAdapter→ input adapters). TheonBlurplumbing is in place for future use but is not actively wired in this change.collectInputComponentsto walk the nested component tree (BLOCK → STACK → inputs) so thatvalidateFieldFormatcan find input fields regardless of nesting depth. Previously, only top-level components were stored, causing per-field validation to silently skip nested inputs. TheupdateInputhandler debounces 600ms then runs format-only validation.@thunderid/reactSDK does not exposehandleInputBlurin SignUp/Recovery render props, local validation state is maintained and merged with SDK-provided errors viamergeErrors.handleInputBlurwiring for consistency with the other forms (required validation on submit only).Screen.Recording.2026-07-28.at.11.42.31.mov
Related Issues
Related PRs
Checklist
breaking changelabel added.Security checks
Summary by CodeRabbit
New Features
Bug Fixes