Skip to content

Comments

Reset Add Connection modal state on close#26

Merged
mkobayashime merged 2 commits intomainfrom
reset-new-modal
Feb 7, 2026
Merged

Reset Add Connection modal state on close#26
mkobayashime merged 2 commits intomainfrom
reset-new-modal

Conversation

@mkobayashime
Copy link
Owner

Summary

  • Fixed modal state persistence issue by using conditional rendering to unmount the component when closed
  • Eliminates stale data (repo selection, srcDir, target folder, step position, errors) when users reopen the modal
  • Simpler and more maintainable than manual state reset logic

Changes

  • Wrapped AddConnectionModal in conditional rendering ({addOpen && ...})
  • Component now unmounts completely when closed, automatically resetting all internal state
  • Added documentation file explaining the approach

Benefits

  • Automatic state reset: No manual cleanup needed
  • React idiomatic: Uses component lifecycle for cleanup
  • Future-proof: Any new state additions automatically reset
  • Clean UX: Modal always starts fresh when reopened

Test plan

  • Open modal, fill out fields, click Cancel → reopen → verify all fields reset
  • Complete full flow to add connection → reopen modal → verify clean state
  • Trigger validation error → close → reopen → verify no error persists
  • Partially fill form (change srcDir) → cancel → reopen → verify srcDir back to "/"

Use conditional rendering to unmount the modal when closed,
automatically resetting all internal states (currentStep, repo,
srcDir, targetFolder, error, submitting, and folder tree state).
This provides a clean slate when users reopen the modal.
@mkobayashime mkobayashime merged commit c011497 into main Feb 7, 2026
1 check passed
@mkobayashime mkobayashime deleted the reset-new-modal branch February 7, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant