Skip to content

Fix closing dialog at page to add new field resulting in an error page#242

Merged
SvenVw merged 2 commits into
developmentfrom
FDM218
Aug 15, 2025
Merged

Fix closing dialog at page to add new field resulting in an error page#242
SvenVw merged 2 commits into
developmentfrom
FDM218

Conversation

@BoraIneviNMI
Copy link
Copy Markdown
Collaborator

@BoraIneviNMI BoraIneviNMI commented Aug 14, 2025

  • Bug Fixes
    • Dismissing the add field dialog in the add field atlas screen no longer produces an error.

Closes #218

Summary by CodeRabbit

  • Bug Fixes

    • Dismissing the Add Field dialog on the Add Field Atlas screen no longer causes an error.
    • Closing the dialog now reliably clears the previously selected field, preventing stale selections from persisting.
  • Chores

    • Added release metadata for a patch update to document the fix.

@BoraIneviNMI BoraIneviNMI self-assigned this Aug 14, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Aug 14, 2025

🦋 Changeset detected

Latest commit: fb59ff3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@svenvw/fdm-app Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 14, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
Release metadata
\.changeset/fifty-lemons-notice.md
Adds patch changeset for @svenvw/fdm-app documenting a bug fix for closing the add field dialog.
Add Field dialog state handling
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
Introduces setDialogOpen to centralize open/close logic; on close, clears selectedField and closes dialog. Passes setDialogOpen to FieldDetailsDialog.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Prevent error when closing add-field dialog (click outside or X) and return to map view (#218)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation

Possibly related PRs

Suggested labels

fdm-app, bug

Suggested reviewers

  • SvenVw
  • gerardhros

Poem

A nibble of code, a hop, then clear—
The dialog shuts, no errors near.
I twitch my whiskers, state is clean,
The map returns with fields pristine.
Thump-thump! I celebrate the patch—
Bugs beware this bunny’s catch. 🐇✨

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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch FDM218

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.78%. Comparing base (34c29ff) to head (fb59ff3).
⚠️ Report is 3 commits behind head on development.

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           
Flag Coverage Δ
fdm-calculator 94.15% <ø> (ø)
fdm-core 91.73% <ø> (ø)
fdm-data 94.37% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BoraIneviNMI BoraIneviNMI marked this pull request as ready for review August 15, 2025 08:13
@BoraIneviNMI BoraIneviNMI requested a review from SvenVw August 15, 2025 08:13
@coderabbitai coderabbitai Bot added bug Something isn't working fdm-app labels Aug 15, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.changeset/fifty-lemons-notice.md (1)

1-5: Changelog entry reads well and matches the fix scope

Clear, 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> contract

If FieldDetailsDialog’s prop type for setOpen is React.Dispatch<React.SetStateAction>, passing a narrower function (value: boolean) => void can 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 34c29ff and fb59ff3.

📒 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.setOpen

The 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 (uses onOpenChange={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}

Copy link
Copy Markdown
Collaborator

@SvenVw SvenVw left a comment

Choose a reason for hiding this comment

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

I checked it and it works. Thanks!

@SvenVw SvenVw merged commit b35c765 into development Aug 15, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fdm-app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closing dialog at page to add new field results into error page

2 participants