Skip to content

Auto-save tile edits in edit dashboard tile modal #1668

Closed

Description

@MikeShi42

Often times it can be hard to remember you need to save the tile you're editing in the editor modal before closing - or else your changes are lost. We should experiment with just auto-saving the change on exit (but perserving cancel to still discard edits). We should toast on exit to make sure users understand we are now auto-saving queries. We can still keep the save button as-is for familiarity.

Need to update EditTileModal in packages/app/src/DBDashboardPage.tsx

Activity

  1. MikeShi42 commented on Jan 28, 2026

    @MikeShi42
    ContributorAuthor

    @claude can you help implement this adjustment to close behavior?

  2. claude commented on Jan 28, 2026

    @claude

    Claude finished @MikeShi42's task in 2m 14s —— View job • claude/issue-1668-20260128-0723 • Create PR ➔


    Implementing Auto-Save for Edit Dashboard Tile Modal

    Tasks

    • Read project documentation and understand codebase patterns
    • Read and analyze current EditTileModal implementation
    • Implement auto-save on modal close
    • Add toast notification for auto-save
    • Ensure cancel button still discards changes
    • Test changes if possible
    • Commit and push changes
    • Provide PR creation link

    Implementation Details

    I've successfully implemented the auto-save functionality with the following changes in DBDashboardPage.tsx:

    Changes made:

    1. Added useRef import for tracking the submit function
    2. Modified EditTileModal to:
      • Track a submitRef that gets the latest save function from EditTimeChartForm
      • Added a handleClose function that distinguishes between cancelling and closing
      • When closing (X button or backdrop click): Triggers auto-save via submitRef.current() and shows a toast notification
      • When cancelling (Cancel button): Discards changes without saving
      • Shows green toast notification "Tile changes auto-saved" when auto-saving

    User experience:

    • Save button: Still works as before for manual saving
    • Cancel button: Explicitly discards changes (no auto-save)
    • Close button/backdrop: Auto-saves changes and shows toast notification
    • The save button remains for familiarity as requested

    Summary

    The implementation addresses the issue where users often forget to save before closing the modal. Now, closing the modal (via X button or clicking outside) will automatically save the changes with a toast notification. Users can still explicitly discard changes using the Cancel button, and the Save button is preserved for familiarity.


    Branch: claude/issue-1668-20260128-0723 |

  3. added a commit that references this issue on Jan 28, 2026
    4f6cba0
  4. MikeShi42 commented on Jan 28, 2026

    @MikeShi42
    ContributorAuthor

    @claude you need to save by using the handleSubmit(handleSave) call in the save button in the file packages/app/src/components/DBEditTimeChartForm.tsx the current ref approach does not work as it won't actually save anything.

  5. claude commented on Jan 28, 2026

    @claude

    Claude finished @MikeShi42's task in 1m 49s —— View job • claude/issue-1668-20260128-0751 • Create PR ➔


    Fixed Auto-Save Implementation

    Tasks

    • Read current implementation in DBDashboardPage.tsx
    • Read DBEditTimeChartForm.tsx to understand the save mechanism
    • Implement correct auto-save using handleSubmit(handleSave)
    • Commit and push changes
    • Provide PR creation link

    Summary

    Fixed the auto-save implementation to properly use handleSubmit(handleSave) from the form's save button. The previous ref-based approach didn't work because it bypassed React Hook Form's validation and save processing logic.

    Implementation Details

    Changes made:

    1. DBEditTimeChartForm.tsx (line 746-750):

      • Modified the submitRef to expose handleSubmit(handleSave) instead of just onSubmit
      • This ensures the proper form validation and save process is triggered when called externally
    2. DBDashboardPage.tsx:

      • Added useRef import
      • Modified EditTileModal to:
        • Create a submitRef to receive the save function from the form
        • Track shouldCancel state to distinguish between cancel and close actions
        • handleClose: Triggers auto-save via submitRef.current() and shows green toast notification "Tile changes auto-saved"
        • handleCancel: Sets the cancel flag to skip auto-save
      • Modal's onClose prop now calls handleClose (triggered by X button and backdrop clicks)
      • Form's onClose prop (Cancel button) now calls handleCancel (to skip auto-save)

    User experience:

    • Save button: Works as before for manual saving
    • Cancel button: Explicitly discards changes without saving
    • Close button (X) / backdrop click: Auto-saves changes and shows toast notification
    • Save button remains for familiarity as requested

    --- • Branch: claude/issue-1668-20260128-0751

  6. MikeShi42 commented on Jan 28, 2026

    @MikeShi42
    ContributorAuthor

    @claude do not modify submitRef, please pass another ref if needed. Additionally, you need to run yarn lint to validate changes before committing.

  7. claude commented on Jan 28, 2026

    @claude

    Claude finished @MikeShi42's task in 2m 34s —— View job • claude/issue-1668-20260128-0755 • Create PR ➔


    Fixed Auto-Save Implementation

    Tasks

    • Read project documentation (CLAUDE.md)
    • Read current implementation to understand the issue
    • Implement fix using a separate ref (not modifying submitRef)
    • Run yarn lint to validate changes
    • Fix any linting errors
    • Commit and push changes
    • Provide PR creation link

    Implementation Summary

    Fixed the auto-save implementation by creating a separate autoSaveRef prop instead of modifying the existing submitRef.

    Changes Made:

    DBEditTimeChartForm.tsx (packages/app/src/components/DBEditTimeChartForm.tsx):

    • Added autoSaveRef as a new optional prop (line 532)
    • Moved handleSave definition before the useEffect hooks to fix dependency order (line 747)
    • Added a separate useEffect to assign handleSubmit(handleSave) to autoSaveRef (lines 754-758)
    • The existing submitRef prop remains completely untouched

    DBDashboardPage.tsx (packages/app/src/DBDashboardPage.tsx):

    • Added useRef import (line 7)
    • Created autoSaveRef in EditTileModal component (line 522)
    • Added shouldCancel state to distinguish between cancel and close actions (line 523)
    • Implemented handleClose: Auto-saves via autoSaveRef.current() and shows green toast notification "Tile changes auto-saved" (lines 525-535)
    • Implemented handleCancel: Sets cancel flag to skip auto-save (lines 537-540)
    • Modal's onClose prop now calls handleClose (triggered by X button and backdrop clicks) (line 545)
    • Form's onClose prop now calls handleCancel (triggered by Cancel button) (line 567)

    User Experience:

    • Save button: Works as before for manual saving
    • Cancel button: Explicitly discards changes without auto-saving
    • Close button (X) / backdrop click: Auto-saves changes and shows toast notification
    • Save button remains for familiarity as requested

    Note: I was unable to run yarn lint directly as it requires approval in this environment. However, I reviewed the code carefully and fixed the dependency order issue in the useEffect hook that would have caused a linting error.


    • Branch: claude/issue-1668-20260128-0755

  8. pulpdrew commented on Jun 4, 2026

    @pulpdrew
    Contributor

    Closing, as we've added a confirmation dialog to prevent accidentally discarding tile changes, and prefer that over auto-saving tile edits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrontendCreated by Linear-GitHub Sync

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions