From 9365d16452f4c26c5add8676cef5269ccc6b78f8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 15 Feb 2026 21:46:44 +0200 Subject: [PATCH] fix: replace onCloseRequested with beforeunload to fix window close The Tauri onCloseRequested async handler was preventing the window from actually closing. Using beforeunload for the save flush instead. --- src/App.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 07314a1..a98f9ab 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,4 @@ import { useState, useEffect, useCallback } from "react"; -import { getCurrentWindow } from "@tauri-apps/api/window"; import { AnimatePresence, motion } from "framer-motion"; import { springs, fadeSlideLeft, fadeSlideRight } from "@/lib/motion"; import { useAppStore } from "@/stores/app-store"; @@ -27,11 +26,12 @@ export default function App() { // Flush pending board saves before the app window closes useEffect(() => { - const unlisten = getCurrentWindow().onCloseRequested(async () => { + function handleBeforeUnload() { useBoardStore.getState().closeBoard(); - }); + } + window.addEventListener("beforeunload", handleBeforeUnload); return () => { - unlisten.then((fn) => fn()); + window.removeEventListener("beforeunload", handleBeforeUnload); }; }, []);