Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] two problems of menus on tauri v2 #7828

Closed
percy507 opened this issue Sep 13, 2023 · 6 comments
Closed

[bug] two problems of menus on tauri v2 #7828

percy507 opened this issue Sep 13, 2023 · 6 comments
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@percy507
Copy link

Describe the bug

  1. There are three native menus failed to apply custom text.

    Source code: click here

image
  1. I change different window's menu bar by listening WindowEvent::Focused in on_window_event. But re-focus window will make app crashed.

    Source code: click here

2023-09-13 20:23:15.272 tauri-app[18787:10077111] *** Assertion failure in -[NSMenu dealloc], NSMenu.m:409
thread 'main' panicked at 'Uncaught exception <NSException: 0x12c3aaea0>', /Users/m2/.cargo/registry/src/index.crates.io-6f17d22bba15001f/muda-0.8.7/src/platform_impl/macos/mod.rs:57:25

Reproduction

https://github.com/percy507/test-tauri-v2

Expected behavior

No response

Platform and versions

tauri "info"

[✔] Environment
    - OS: Mac OS 13.2.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.72.0 (5680fa18f 2023-08-23)
    ✔ Cargo: 1.72.0 (103a7ff2e 2023-08-15)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 16.10.0
    - pnpm: 7.9.5
    - yarn: 1.22.19
    - npm: 7.24.0

[-] Packages
    - tauri [RUST]: 2.0.0-alpha.12
    - tauri-build [RUST]: 2.0.0-alpha.8
    - wry [RUST]: 0.32.0
    - tao [RUST]: 0.22.2
    - @tauri-apps/api [NPM]: 2.0.0-alpha.6
    - @tauri-apps/cli [NPM]: 2.0.0-alpha.12

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

No response

Additional context

No response

@pewsheen
Copy link
Contributor

Thanks for reporting!

The first one I'm not sure if those texts are controlled by the system. I'll try some ways to find out.
The second problem could be another autorelease issue :\

@pewsheen
Copy link
Contributor

The first problem is a weird behavior of the macOS that we can't set the title for some system-defined actions.

This also happened to the electron (ref) and they wrapped it with another custom action to avoid that.

I also found that if we are using attributedTitle then the title will be changed to what we provide, but I'm not sure what would be the side-effect.

@amrbashir How do you think?

@amrbashir
Copy link
Member

@pewsheen lets use a custom selector then like electron.

@pewsheen
Copy link
Contributor

@pewsheen lets use a custom selector then like electron.

I just know why macOS is controlling these items 🥲

Redo and undo are controlled by the window's NSUndoManager. Those items' titles are localized by the system and changed depending on the step's action name, like "Typing", "Delete", or "Copy" and become "Undo Typing / Delete / Copy". Also, the item's enabled state is controlled by the UndoManager as well. The undo/redo buttons are enabled or disabled corresponding to the action state registered in the UndoManager.

toggleFullScreen has similar behavior. When the window is entered full-screen mode, the title will be changed to "Exit Full Screen".

If we want to wrap these methods, each time we set a new title for the menu item we need to create a subclass of NSUndoManager and override the title methods, and then replace the window's UndoManager with this new one.

@amrbashir
Copy link
Member

I'd say go with what you feel best and then we can discuss your approach in the PR other than speculating here.

@percy507
Copy link
Author

percy507 commented Jan 2, 2024

The first bug seems have been fixed. (Test on tauri 2.0.0-alpha.20)

The second bug I open a new issue. #8465

@percy507 percy507 closed this as completed Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

3 participants