[bug] Tauri App's Close Functionality Fails After Minimize/Maximize Actions (Windows)
Describe the bug
Encountered an issue where minimizing and then attempting to close a Tauri application. Results in the close handler losing its scope. This prevents the close handler from functioning as expected.
Minimal Reproduction Example
Behavior Observed
The application is set up to intercept the WINDOW_CLOSE_REQUESTED event and prevent the default behavior, which typically closes the application. Instead, it invokes a Tauri command to hide the window. The application features a system tray implementation which allows it to remain open in the background and can be reopened with a click event on the system tray icon.
Additional Notes
This issue seems to be triggered by specific interactions with window size adjustments and the taskbar functionalities when the application is in a minimized state.
I also have not tested this on Mac and may exist there too.
Reproduction
- Run the application using
npm run tauri dev. - Right-click the application icon in the taskbar and choose "Pin to taskbar".
- Optionally, click "Close" on the application window to observe it hiding instead of closing.
- Click the Tauri icon in the system tray to display the window again. (Note: Clicking the icon pinned to the taskbar won't show the window in dev mode.)
- Simultaneously press
Win + Up ArrowandWin + Down Arrowto alternate window size. During this, right-click the pinned taskbar icon and choose "Close", while continuing to alternate window size with the arrows. - Attempt to close the application by clicking the 'X' button; observe that the application does not hide as expected, indicating a malfunction.
Expected behavior
The close handler to continue to function as a close handler
Full tauri info output
[✔] Environment
- OS: Windows 10.0.22621 X64
✔ WebView2: 123.0.2420.97
✔ MSVC:
- Visual Studio Build Tools 2017
- Visual Studio Build Tools 2022
✔ rustc: 1.77.1 (7cf61ebde 2024-03-27)
✔ cargo: 1.77.1 (e52e36006 2024-03-26)
✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 18.14.0
- npm: 9.3.1
[-] Packages
- tauri [RUST]: 1.6.1
- tauri-build [RUST]: 1.5.1
- wry [RUST]: 0.24.7
- tao [RUST]: 0.16.8
- @tauri-apps/api [NPM]: 1.5.3
- @tauri-apps/cli [NPM]: 1.5.11
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../dist
- devPath: http://localhost:1420/
- framework: Vue.js
- bundler: Vite
Stack trace
No response
Additional context
https://github.com/tauri-apps/tauri/assets/3421501/20941d02-0d2c-482d-a193-3ebaa2ac019b