Skip to content

Commit 6abc0f0

Browse files
committed
fix: prevent partial reset when canceling reset confirmation
1 parent 84a5696 commit 6abc0f0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/components/MDX/Sandpack/NavigationBar.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ export function NavigationBar({providedFiles}: {providedFiles: Array<string>}) {
103103
*
104104
* Plus, it should only prompt if there's any file changes
105105
*/
106-
if (
107-
sandpack.editorState === 'dirty' &&
108-
confirm('Reset all your edits too?')
109-
) {
106+
if (sandpack.editorState === 'dirty') {
107+
const confirmed = confirm('Reset all your edits too?');
108+
if (!confirmed) return;
110109
sandpack.resetAllFiles();
111110
}
112111

0 commit comments

Comments
 (0)