Skip to content

Conversation

@krrish175-byte
Copy link

@krrish175-byte krrish175-byte commented Oct 29, 2025

Addressing Issue #10259

This PR fixes a bug in the file handling behavior of Excalidraw.
Previously, when a user opened a new .excalidraw file and then clicked Save, the app would still save to the previously opened file’s path.
This could accidentally overwrite the wrong file if the user wasn’t careful.

Changes made

  • Updated logic in src/excalidraw-app/data/json.ts
  • After opening a file via fileOpen(), the opened file’s handle is now correctly stored in appState.fileHandle
  • This ensures subsequent saves target the newly opened file instead of the last one

Technical Explanation
The bug occurred because appState.fileHandle wasn’t being updated after loading a file from disk.
Now, inside loadFromJSON() (in json.ts), we assign:
return loadFromBlob(file, localAppState, localElements, file.handle);
so the handle gets preserved and used on the next save.

Testing Done

  • Opened and saved multiple files in sequence.
  • Verified correct overwrite behavior.
  • No regression in other save/load behavior.

@vercel
Copy link

vercel bot commented Oct 29, 2025

@krrish175-byte is attempting to deploy a commit to the Excalidraw Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Oct 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
excalidraw Ready Ready Preview Oct 29, 2025 7:46am

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