Repository navigation
fix: input-group don't have the proper validation attributes - #44703
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughReordered Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/studio/components/interfaces/Settings/Database/DiskSizeConfigurationModal.tsx`:
- Around line 199-209: The FormControl_Shadcn_ is currently wrapping both
InputGroupInput and InputGroupAddon which alters composition and can break
validation/prop forwarding; update the JSX so that InputGroup contains two
direct children: a FormControl_Shadcn_ that wraps only the InputGroupInput (pass
{...field}, id, type, onChange to InputGroupInput inside FormControl_Shadcn_),
and an InputGroupAddon as the sibling (with InputGroupText "GB") so the addon is
not nested inside FormControl_Shadcn_. Ensure InputGroup remains the parent
element.
🪄 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: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 070b0e3c-0b4c-42be-8fee-87327a494f07
📒 Files selected for processing (17)
apps/studio/components/interfaces/Auth/AuthProvidersForm/FormField.tsxapps/studio/components/interfaces/Auth/MfaAuthSettingsForm/MfaAuthSettingsForm.tsxapps/studio/components/interfaces/Auth/PerformanceSettingsForm.tsxapps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsxapps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsxapps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/AdvancedSettings.tsxapps/studio/components/interfaces/DiskManagement/fields/AutoScaleFields.tsxapps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsxapps/studio/components/interfaces/DiskManagement/fields/IOPSField.tsxapps/studio/components/interfaces/DiskManagement/fields/ThroughputField.tsxapps/studio/components/interfaces/JwtSecrets/jwt-settings.tsxapps/studio/components/interfaces/Realtime/RealtimeSettings.tsxapps/studio/components/interfaces/Settings/API/PostgrestConfig.tsxapps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsxapps/studio/components/interfaces/Settings/Database/DiskSizeConfigurationModal.tsxpackages/ui/src/components/shadcn/ui/input-group.tsx
There was a problem hiding this comment.
Additional findings (outside current diff — PR may have been updated during review):
-
🔴
packages/ui/src/components/shadcn/ui/input-group.tsx:133-160— InputGroupInput and InputGroupTextarea now unconditionally call useFormField() (input-group.tsx lines 136 and 162), which calls useFormContext() from react-hook-form. Since react-hook-form creates its context with createContext(null), calling these components outside a <Form_Shadcn_> or wrapper throws a TypeError: 'Cannot destructure property of null'. The ui-patterns DataInputs/Input.tsx wrapper uses InputGroupInput directly without any form context (lines 75-88), and that component is used throughout the studio (e.g., DisplayApiSettings.tsx, FilterPopover.tsx) without form context — those call sites will crash at render time after this PR.Extended reasoning...
What the bug is and how it manifests
InputGroupInput and InputGroupTextarea now call useFormField() unconditionally at render time (input-group.tsx lines ~136 and ~162). useFormField() calls useFormContext() from react-hook-form internally (form.tsx line 47). In react-hook-form v7, useFormContext() is created via createContext(null), so it returns null when there is no FormProvider ancestor. The code then does:
const { getFieldState, formState } = useFormContext()
When useFormContext() returns null, this destructuring throws: TypeError: Cannot destructure property 'getFieldState' of null.
The specific code path that triggers it
packages/ui-patterns/src/DataInputs/Input.tsx renders InputGroupInput directly (lines 75-88) without wrapping it in a Form_Shadcn_ or FormProvider. That Input component is used as a general-purpose UI primitive, not a form-specific component. Callers like DisplayApiSettings.tsx, FilterPopover.tsx, ColumnList.tsx, and TableList.tsx render this Input component outside any form context. After this PR, every such call site will crash on render.
Why existing code does not prevent this
The PR author noted that FormControl_Shadcn_ passes id, aria-invalid, and aria-describedby to InputGroup, and that InputGroupInput needs to read these itself. The chosen fix was to call useFormField() directly inside InputGroupInput/InputGroupTextarea. However, useFormField() has no graceful fallback when called outside a FormProvider - it relies on FormContext being non-null, and throws on null. The null check at form.tsx line 51 (if (!fieldContext)) is dead code because FormFieldContext defaults to an empty object {} (truthy), so the guard never triggers and the crash happens at the useFormContext() call above it.
What the impact would be
Any consumer of InputGroupInput or InputGroupTextarea that is not inside a Form_Shadcn_/FormProvider will throw a TypeError and crash, producing a broken UI. The most immediate impact is the general-purpose ui-patterns Input wrapper, which is used in non-form UI across the studio - search/filter UIs, API settings displays, column/table list sidebars, etc.
How to fix it
Use a defensive check before destructuring. For example, wrap useFormContext() in a try/catch, or check whether the context is non-null before calling useFormField(). A cleaner alternative is to introduce a dedicated React context to pass form field state from InputGroup down to its children, avoiding the dependency on FormProvider altogether.
Step-by-step proof
- User renders Input copy reveal from ui-patterns/DataInputs/Input.tsx outside any form.
- Input.tsx renders InputGroupInput at line ~83.
- InputGroupInput calls useFormField() unconditionally at line ~136 of input-group.tsx.
- useFormField() calls useFormContext() (form.tsx line 47), which returns null (no FormProvider in tree).
- const { getFieldState, formState } = null throws TypeError.
- React renders an error boundary or blank screen for that component subtree.
🎭 Playwright Test ResultsDetails
Flaky testsFeatures › database-webhooks.spec.ts › Database Webhooks › can edit a webhook with correct toast message Skipped testsFeatures › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/ui/src/components/shadcn/ui/input-group.tsx`:
- Around line 165-167: The aria-describedby construction currently concatenates
possibly undefined IDs (formItemId, formDescriptionId, formMessageId) causing
strings like "undefined" to be serialized; update the logic in the component
that uses useFormField() (and in the related block around lines using
formItemId/formDescriptionId/formMessageId) to build an array of only defined
IDs, join them with a space, and pass undefined when the resulting string is
empty so aria-describedby is either a valid id list or undefined; ensure the
same fix is applied to the other occurrence referenced (the block that sets
aria-describedby for InputGroupInput/InputGroupTextarea).
🪄 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: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 2a6dd159-c71a-4bd4-97f9-19dc698e2ea0
📒 Files selected for processing (2)
apps/studio/components/interfaces/Auth/PerformanceSettingsForm.tsxpackages/ui/src/components/shadcn/ui/input-group.tsx
✅ Files skipped from review due to trivial changes (1)
- apps/studio/components/interfaces/Auth/PerformanceSettingsForm.tsx
Braintrust eval report
|
## What kind of change does this PR introduce? Bug fix. Resolves FE-2959. ## What is the current behaviour? Grouped inputs strip the inner control border with `border-0`, while the outer `InputGroup` is responsible for the visible outline. After #44703, grouped form inputs now receive the correct validation attributes, but the primitive still removes the inner border dimensions entirely. That keeps the visual layer brittle and can lead to inconsistent error rendering, especially in light mode where the grouped password field does not match the Project name input. The shared `ui-patterns` input wrapper also inherits the generic `inline-end` button spacing from `InputGroupAddon`, which pushes the password copy button slightly too far to the right. ## What is the new behaviour? The shared grouped-input primitive now keeps a transparent inner border instead of removing border widths entirely. The outer `InputGroup` continues to own the visible border, focus ring and error treatment, but the inner control now has stable border metrics and no redundant dark-mode background override. The grouped invalid state now also matches the plain input treatment more closely: - unfocused error border uses `destructive-400` - focused error border uses `destructive` - error background uses `destructive-200` The `ui-patterns` input wrapper now overrides the inherited `inline-end` negative margin for its own copy/reveal button addon, so the password copy button sits in the right place without changing spacing for other direct `InputGroup` consumers. | Before | After | | --- | --- | | <img width="1338" height="284" alt="CleanShot 2026-04-09 at 13 43 50@2x-91489355-5EEA-4884-BAA2-B93B28F1D7CB" src="https://github.com/user-attachments/assets/ed40683b-8a87-4deb-8a0f-f892d00894f0" />| <img width="1334" height="278" alt="CleanShot 2026-04-09 at 13 41 36@2x-5D7E930B-EDB2-4002-9367-34ACE2DF4DB4" src="https://github.com/user-attachments/assets/7d9594a4-9988-480e-a809-9f5ed29e8e24" /> | | <img width="1336" height="210" alt="CleanShot 2026-04-09 at 14 06 15@2x-05379F74-4CA5-4E6E-9250-CBA2764C1318" src="https://github.com/user-attachments/assets/25e48cd4-de0a-47f3-9022-d7a3829a0626" /> | <img width="1334" height="210" alt="CleanShot 2026-04-09 at 14 12 11@2x-11FBC519-D398-4A59-971A-97FBFEF610DE" src="https://github.com/user-attachments/assets/91c3710c-7773-4286-854d-7b7144db85ab" /> | An easy place to test this is the Database password field in the New Project creation flow. See also the Minimum password length field in Email (Sign In / Providers). ## Summary - update `packages/ui/src/components/shadcn/ui/input-group.tsx` - replace `border-0` on grouped inputs/textareas with transparent borders - remove the redundant `dark:bg-transparent` - keep the inner grouped controls visually neutral so the outer group owns the rendered border state - align grouped invalid border and background styling with the plain input treatment - update `packages/ui-patterns/src/DataInputs/Input.tsx` so copy/reveal buttons do not inherit the extra right pull intended for other `inline-end` addons
## Problem The input groups components introduced in #44282 don't have the validation attributes when invalid. This hurts accessibility and also break the design: <img width="1730" height="324" alt="image" src="https://github.com/user-attachments/assets/a3fb8d86-f3a8-46bb-aa53-d0599c11f056" /> ## Solution This is because the wrapper `<FormControl_Shadcn_>` passes the validation props to its direct child. The solution is to avoid applying them on the `<InputGroup>` and to apply them manually on the inputs. I also fixed a small accessibility issue by moving the addon texts after the input so that screen readers announce them in the correct order. No visual change for this <img width="587" height="158" alt="image" src="https://github.com/user-attachments/assets/1f8858ea-6659-45f9-964e-8c43a7fe14ba" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Unified numeric input layout by moving unit labels/suffixes (e.g., "seconds", "GB", "%", "connections", "digits", "IOPS", "MB/s", "rows") to appear after their inputs for a consistent, predictable form appearance. * **Accessibility** * Form controls now expose IDs and ARIA attributes from form context when available, improving screen-reader descriptions and error association. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Ivan Vasilov <[email protected]>
## What kind of change does this PR introduce? Bug fix. Resolves FE-2959. ## What is the current behaviour? Grouped inputs strip the inner control border with `border-0`, while the outer `InputGroup` is responsible for the visible outline. After #44703, grouped form inputs now receive the correct validation attributes, but the primitive still removes the inner border dimensions entirely. That keeps the visual layer brittle and can lead to inconsistent error rendering, especially in light mode where the grouped password field does not match the Project name input. The shared `ui-patterns` input wrapper also inherits the generic `inline-end` button spacing from `InputGroupAddon`, which pushes the password copy button slightly too far to the right. ## What is the new behaviour? The shared grouped-input primitive now keeps a transparent inner border instead of removing border widths entirely. The outer `InputGroup` continues to own the visible border, focus ring and error treatment, but the inner control now has stable border metrics and no redundant dark-mode background override. The grouped invalid state now also matches the plain input treatment more closely: - unfocused error border uses `destructive-400` - focused error border uses `destructive` - error background uses `destructive-200` The `ui-patterns` input wrapper now overrides the inherited `inline-end` negative margin for its own copy/reveal button addon, so the password copy button sits in the right place without changing spacing for other direct `InputGroup` consumers. | Before | After | | --- | --- | | <img width="1338" height="284" alt="CleanShot 2026-04-09 at 13 43 50@2x-91489355-5EEA-4884-BAA2-B93B28F1D7CB" src="https://github.com/user-attachments/assets/ed40683b-8a87-4deb-8a0f-f892d00894f0" />| <img width="1334" height="278" alt="CleanShot 2026-04-09 at 13 41 36@2x-5D7E930B-EDB2-4002-9367-34ACE2DF4DB4" src="https://github.com/user-attachments/assets/7d9594a4-9988-480e-a809-9f5ed29e8e24" /> | | <img width="1336" height="210" alt="CleanShot 2026-04-09 at 14 06 15@2x-05379F74-4CA5-4E6E-9250-CBA2764C1318" src="https://github.com/user-attachments/assets/25e48cd4-de0a-47f3-9022-d7a3829a0626" /> | <img width="1334" height="210" alt="CleanShot 2026-04-09 at 14 12 11@2x-11FBC519-D398-4A59-971A-97FBFEF610DE" src="https://github.com/user-attachments/assets/91c3710c-7773-4286-854d-7b7144db85ab" /> | An easy place to test this is the Database password field in the New Project creation flow. See also the Minimum password length field in Email (Sign In / Providers). ## Summary - update `packages/ui/src/components/shadcn/ui/input-group.tsx` - replace `border-0` on grouped inputs/textareas with transparent borders - remove the redundant `dark:bg-transparent` - keep the inner grouped controls visually neutral so the outer group owns the rendered border state - align grouped invalid border and background styling with the plain input treatment - update `packages/ui-patterns/src/DataInputs/Input.tsx` so copy/reveal buttons do not inherit the extra right pull intended for other `inline-end` addons
Problem
The input groups components introduced in #44282 don't have the validation attributes when invalid. This hurts accessibility and also break the design:

Solution
This is because the wrapper
<FormControl_Shadcn_>passes the validation props to its direct child.The solution is to avoid applying them on the
<InputGroup>and to apply them manually on the inputs.I also fixed a small accessibility issue by moving the addon texts after the input so that screen readers announce them in the correct order. No visual change for this
Summary by CodeRabbit
Style
Accessibility