tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] Updating system tray menu with invoke / tauri command -> unexpected output

Open dgu87 opened this issue 4 years ago • 8 comments

Describe the bug

Updating the tray menu with a tauri command adds unexpected suffixes to the updated titles.

tray1 tray2 tray3

Reproduction

#[tauri::command]
fn locale_de(app: tauri::AppHandle) {
  app.tray_handle().get_item("hide").set_title("Ausblenden").unwrap();
  app.tray_handle().get_item("quit").set_title("Beenden").unwrap();
  app.tray_handle().get_item("open").set_title("Einblenden").unwrap();
}

(...)

.system_tray(system_tray)
.invoke_handler(tauri::generate_handler![locale_de, locale_en, locale_it, locale_es, locale_fr])

Expected behavior

No response

Platform and versions

Operating System - Windows, version 10.0.19043 X64
(...)
Node.js environment
  Node.js - 17.5.0
  @tauri-apps/cli - 1.0.0-rc.4 (outdated, latest: 1.0.0-rc.7)
  @tauri-apps/api - 1.0.0-rc.2

Global packages
  npm - 8.4.1
 (...)

Rust environment
  rustup - 1.24.3
  rustc - 1.58.1
  cargo - 1.58.0
  toolchain - stable-x86_64-pc-windows-msvc
(...)
App
  tauri - git+https://github.com/tauri-apps/tauri?branch=dev#f5efc248da511e0924c9673b947d5de7ef69ac45 (1.0.0-rc.4)
  tauri-build - 1.0.0-rc.4
  tao - 0.6.4
  wry - 0.13.3
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../public
  devPath - http://localhost:5000/
  framework - Svelte
  bundler - Rollup

Stack trace

No response

Additional context

Note: The code posted under "Reproduction" works 100% fine in macOS environments.

dgu87 avatar Mar 08 '22 15:03 dgu87

Will be fixed once https://github.com/tauri-apps/tao/pull/297 is merged and published.

amrbashir avatar Mar 08 '22 15:03 amrbashir

Are you sure? Because i can't repro that issue in tao directly, only in tauri. But i could be doing it wrong, not a tao guy 🤷

FabianLars avatar Mar 08 '22 15:03 FabianLars

Yeah I came across this issue when I was refactoring menus (see here). It was because of a missing \0(null character). windows-rs used to automatically add it but I think there was a regression in one of their recent version so I am gonna make sure it won't break again by manually checking and adding it.

To confirm if this is indeed the issue, try using current tauri version and add \0(null character) in the end. e.g. item.set_title("your new tilte\0") .

amrbashir avatar Mar 08 '22 15:03 amrbashir

Ahh i see, thanks.

And yes appending \0 fixes it (on my end). What it doesn't fix tho, is ÄÖÜ. These chars work fine if you create the item with it, but not in the command above. Any idea if that's auto fixed by that PR too?

FabianLars avatar Mar 08 '22 15:03 FabianLars

What it doesn't fix tho, is ÄÖÜ. These chars work fine if you create the item with it, but not in the command above. Any idea if that's auto fixed by that PR too?

Can you leave a comment there with this info so I don't forget?

Sorry, I can't test it for another 3 weeks but the Windows portion of that PR is done so you can just check the tao PR locally and try.

amrbashir avatar Mar 08 '22 18:03 amrbashir

Can that PR even be part of tauri v1? Probably not, so we'd need a patch specific to this issue anyway.

lucasfernog avatar Mar 08 '22 19:03 lucasfernog

It definitely can, I just couldn't put more work in it this vacation due to some IRL issues, but I should be able to finish it on my next vacation.

But yeah I agree, tao can make a patch for it until the PR is finished. I will make a quick patch for it tomorrow once I get settled, if no one beats me to it.

amrbashir avatar Mar 08 '22 20:03 amrbashir

Tao patch: https://github.com/tauri-apps/tao/pull/340

lucasfernog avatar Mar 09 '22 03:03 lucasfernog