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

Tauri integration #313

Closed
7 of 9 tasks
icidasset opened this issue Jan 29, 2022 · 16 comments · Fixed by #347
Closed
7 of 9 tasks

Tauri integration #313

icidasset opened this issue Jan 29, 2022 · 16 comments · Fixed by #347

Comments

@icidasset
Copy link
Owner

icidasset commented Jan 29, 2022

Tauri integration somewhat works now, but there are issues (and I've only tested on MacOS).

  • Dialogs don't work (eg. for importing data) Fixed
  • Downloading files doesn't work (eg. export button)
  • Opening links in new tabs doesn't work either (eg. Link to help page)
  • Errors regarding the Tauri window in console:
    TypeError: window['5ae98b93-333b-439e-a895-08f45041b522'] is not a function. (In 'window['5ae98b93-333b-439e-a895-08f45041b522']({event: "tauri://resize", payload: {"height":1690,"width":2336}})', 'window['5ae98b93-333b-439e-a895-08f45041b522']' is undefined)
  • Waiting for zoom in/out menu items: More native menu items tauri-apps/tauri#2802
  • Different menus for other operating systems (current one is MacOS specific): feat: add a default menu for tauri apps tauri-apps/tauri#2398
  • Dark mode doesn't work

To dos:

@nothingismagick
Copy link

Hey there. Thanks @schickling for the heads up.

I think that all of these issues have been resolved by the RC, which is now available at crates.io / npm respectively (and is recommended for stability going forward).

Although I am not sure what you mean with Opening links in new tabs (in the browser???)
WRT to "different menus": You have full control over this, so I see it as more of a documentation issue, and macOS needed to be overridden because its default is senseless (IMHO).

@nothingismagick
Copy link

This too has been fixed:

Errors regarding the Tauri window in console:

@icidasset
Copy link
Owner Author

Thanks @nothingismagick !

That is not a function error has indeed been fixed 👍
Not sure what else is supposed to be fixed, so let me clarify the points layed out above:

  1. Dialogs don't work → Meaning alert(), confirm() and prompt().
    As I understand it, this isn't really an issue, but more a feature that's missing?
    Any thoughts on how to approach this?
  2. Downloading files → Downloading a generated file using the download attribute on <a> elements. Don't know what to do this one, related to the next point. Should this work in Tauri?
  3. Open link in a new tab → <a href="..." target="_blank" />, not entirely sure how this should behave in a Tauri app, I guess opening in the browser makes the most sense? Can I configure Tauri so that this is done automatically?

(5) & (6) regarding the menus are indeed not issues with Tauri but things I have yet to address.

@icidasset
Copy link
Owner Author

Clarifying the "import dialog", how this works is:

  1. User clicks <button>
  2. Elm injects a <input type="file" />
  3. Elm clicks <input />

This means I can't replace it with https://tauri.studio/docs/api/js/modules/dialog/

@icidasset
Copy link
Owner Author

<a href="..." target="_blank" /> links should be able to be opened. The default config only allows links matching the regex ^https?://. I've tried to set it to allow everything using { allowlist: { shell: { open: ".*" }}}, but that doesn't seem to work.

@nothingismagick
Copy link

nothingismagick commented Feb 23, 2022

With regard to <a href> do you mean opened in the webview? Should it spawn a new webview? Or should it open a browser tab?

@nothingismagick
Copy link

<input file> if elm is trying to be helpful, but isn't, then you should probably construct your own click handler.

@nothingismagick
Copy link

@nothingismagick
Copy link

Downloading files? I would need to know more about what you mean. From a remote webserver? From the core app? You want it to go to the Downloads folder? I am not trying to be obtuse here, just getting a feeling for what you need.

@icidasset
Copy link
Owner Author

@nothingismagick <a href="..." target="_blank" /> should open in a new web view, or the default browser. Don't have a strong preference. I found out that this should already work in Tauri, but, I'm using relative urls which don't work with the default configuration. I tried adjusting the regex for the allowList, but I couldn't get that to work yet (see comment above for more details).

Downloading files is done using <a download href="blob:uri"> (ie. with a https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL uri from the core app), which does indeed go to the downloads folder.

I did already know about the dialog module, but wanted to stick with alert so it works in the browser as well. Or do you mean Tauri will trigger the dialog module automatically like it does with the <a> elements?

On the Tauri Discord it was suggested to me I could write plugins for <a download> and <input type="file" />, so I might look into that at some point.

@icidasset
Copy link
Owner Author

Import dialog works now, still having trouble opening links in default browser and downloading files with <a href="blob:..." download />

@icidasset
Copy link
Owner Author

Download link isn't supported yet: tauri-apps/wry#349
Might be possible to "polyfill" this using https://tauri.app/v1/api/js/modules/dialog

@nothingismagick
Copy link

Incoming: tauri-apps/wry#530

@icidasset
Copy link
Owner Author

Thanks @nothingismagick !

Discussed the "new tab" links on Discord. Notes:

  • Relative links can't be opened in the browser because of the custom tauri protocol
  • I'm using https://github.com/tauri-apps/tauri-plugin-localhost, so I can somewhat bypass that. But, I'd still need to prefix all my links with the full hostname (eg. http://localhost:44999/about/#UI)
  • Ideally I'd be able to open my relative links in a new window in my app, but no such (HTML) API is available yet (ie. there's no <a href target="_newWindow" /> or something similar)
  • Was told that I could use WebviewWindow (write plugin?)

@icidasset
Copy link
Owner Author

icidasset commented Jul 10, 2022

Setting dark mode explicitly changes the CSS successfully.
It doesn't however detect dark mode automatically when not setting a preferred theme.

By looking at this code, it should do that: https://github.com/tauri-apps/tao/blob/93c256f9835b2da853129f2a1d77287aa714934e/src/platform_impl/windows/dark_mode.rs#L155-L181
But it doesn't work.

(tauri v1.0.3)

@icidasset
Copy link
Owner Author

Dark mode is fixed, may have been a plugin that interfered with the theme detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants