Skip to content

Commit

Permalink
fix: don't alert on beforeunload for empty models
Browse files Browse the repository at this point in the history
  • Loading branch information
j4k0xb committed May 22, 2024
1 parent 5f8835e commit b9ad0db
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions apps/playground/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ function App() {
fileModels().map((model) => model.uri.path),
);

const hasUnsavedChanges = () => models().some((m) => m.getValueLength() > 0);

window.onbeforeunload = () => hasUnsavedChanges();
window.onbeforeunload = () =>
models().some((m) => m.getValueLength() > 0) || undefined;

// eslint-disable-next-line @typescript-eslint/no-misused-promises
const saveModelsDebounced = debounce(() => saveModels(models()), 1000);
Expand Down

0 comments on commit b9ad0db

Please sign in to comment.