Fix closing dialog at page to add new field resulting in an error page#242
Conversation
🦋 Changeset detectedLatest commit: fb59ff3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughAdds a changeset for a patch release and updates the add-field route to clear selectedField when the dialog closes by introducing a setDialogOpen helper. FieldDetailsDialog now receives setDialogOpen to ensure state reset on close. No exported/public APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FieldDetailsDialog
participant AddFieldRoute as Route Component
User->>FieldDetailsDialog: Close (outside click or X)
FieldDetailsDialog->>AddFieldRoute: setDialogOpen(false)
AddFieldRoute->>AddFieldRoute: setSelectedField(null), setOpen(false)
AddFieldRoute-->>User: Dialog closed, map visible
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## development #242 +/- ##
============================================
Coverage 92.78% 92.78%
============================================
Files 87 87
Lines 13091 13091
Branches 1316 1316
============================================
Hits 12146 12146
Misses 943 943
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
.changeset/fifty-lemons-notice.md (1)
1-5: Changelog entry reads well and matches the fix scopeClear, concise patch note aligned with the PR objective (fix dialog dismissal error).
If you want extra traceability, consider appending a short reference to the linked issue:
Dismissing the add field dialog in the add field atlas screen no longer produces an error. +Closes #218.fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx (1)
213-221: Broaden setDialogOpen’s type to fully satisfy React’s Dispatch<SetStateAction> contractIf FieldDetailsDialog’s prop type for setOpen is React.Dispatch<React.SetStateAction>, passing a narrower function
(value: boolean) => voidcan be rejected under strictFunctionTypes or break if the child calls it with an updater function. Safest is to accept both boolean and updater functions and normalize internally.Proposed change:
-function setDialogOpen(value: boolean) { - if (value) { +function setDialogOpen(value: boolean | ((prev: boolean) => boolean)) { + const nextOpen = typeof value === "function" ? value(open) : value + if (nextOpen) { setOpen(true) } else { setSelectedField(null) setOpen(false) } }This preserves your close-on-dismiss behavior and remains compatible if the child calls with a functional updater.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.changeset/fifty-lemons-notice.md(1 hunks)fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx(2 hunks)
🔇 Additional comments (1)
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx (1)
352-352: Approved — setDialogOpen is compatible with FieldDetailsDialog.setOpenThe prop is typed as a boolean-only setter, so passing the wrapper is correct and no prop change is required.
Files verified:
- fdm-app/app/components/blocks/field/form.tsx — interface FieldDetailsDialogProps:
setOpen: (value: boolean) => void(usesonOpenChange={setOpen})- fdm-app/app/components/blocks/field/popup.tsx — same
setOpen: (value: boolean) => void- fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx —
function setDialogOpen(value: boolean) { ... }and usage:setOpen={setDialogOpen}Snippet (unchanged):
setOpen={setDialogOpen}
SvenVw
left a comment
There was a problem hiding this comment.
I checked it and it works. Thanks!
Closes #218
Summary by CodeRabbit
Bug Fixes
Chores