A broken project file should not get to ask whether it can replace your work.
In my downloadable browser chart editor, opening a saved project can replace the chart someone is editing. I added a confirmation for unsaved changes, then tested the order of operations. The important case was not clicking OK. It was uploading an invalid file while edits were waiting.
Validate before asking to replace
My import path follows this order:
Read and parse the candidate file.
Validate its project format and values without changing the current editor.
If the current editor has unsaved changes, ask whether to replace them.
Apply the validated project only after acceptance.
Record the imported state as the new clean baseline.
If validation fails, the existing chart stays in place. There is no overwrite question because there is no usable replacement to approve.
That distinction matters for a chart editor. A file can be valid JSON but contain unusable chart data.…