feat: disable save button on validation errors + server-side error docs#69
feat: disable save button on validation errors + server-side error docs#69
Conversation
…-side error docs
- Add `hasErrors` to SaveButtonRenderProps so consumers can disable save on errors
- Add `hasScopeErrors(scopeId)` to SettingsContextValue for scope-level error checks
- Block handleSave internally when scope has validation errors
- Add server-side validation error documentation with examples in Settings.mdx
- Add dedicated ServerSideValidation story demonstrating error flow
- Update all docs and examples to use `disabled={!dirty || hasErrors}`
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR adds per-scope error detection and plumbs a new hasErrors flag into the Settings save flow: SettingsContext gains hasScopeErrors(scopeId), SettingsContent prevents saves when errors exist and passes hasErrors into renderSaveButton, and docs/examples are updated to reflect the API change. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Form as Settings Form
participant Context as SettingsContext
participant Content as SettingsContent
participant RenderBtn as renderSaveButton
User->>Form: Edit fields (may add errors)
Form->>Context: Update errors state
User->>Content: Attempts to Save (click)
Content->>Context: hasScopeErrors(scopeId)?
Context-->>Content: hasErrors = true/false
Content->>RenderBtn: renderSaveButton({dirty, hasErrors, onSave})
RenderBtn-->>User: Render Save (disabled if !dirty || hasErrors)
alt hasErrors == false and dirty == true
User->>Content: Click enabled Save
Content->>Content: handleSave checks !hasErrors
Content->>Context: invoke onSave(...)
Content-->>User: Save completes
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
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 |
…tities Fixes ESLint react-hooks/rules-of-hooks and react/no-unescaped-entities errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
hasErrors: booleantoSaveButtonRenderPropsso consumers can disable the save button when fields have validation errorshasScopeErrors(scopeId)helper toSettingsContextValuefor scope-level error checkinghandleSaveinternally when the scope has validation errors{ errors: { fieldKey: "message" } }fromonSave)Test plan
npm run typecheckandnpm run lint— both pass🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation