Skip to content
New issue

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

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

Already on GitHub? # to your account

[bug] api/dialog/dialogOpen parameter defaultPath does not work on Windows with slash separators #8074

Closed
qu1ck opened this issue Oct 21, 2023 · 4 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@qu1ck
Copy link

qu1ck commented Oct 21, 2023

Describe the bug

When calling dialogOpen, defaultPath parameter is supposed to specify which folder will be opened initially.
On windows it works only if backslash is used as path separator, if a forward slash is used then the parameter is ignored.

I realize this is likely a limitation of winapi but it looks like something that is very easy to fix in rust side of the api. Yes, it can be worked around in javascript side but I think Tauri should take care of it since this is both undocumented and not obvious to rootcause when troubleshooting.

Reproduction

This works

dialogOpen({
  title: "Select directory",
  defaultPath: "D:\tmp",
  directory: true,
}

This does not

dialogOpen({
  title: "Select directory",
  defaultPath: "D:/tmp",
  directory: true,
}

and will open the last used directory or current working directory

Expected behavior

dialogOpen should work with both "\" and "/" on windows

Platform and versions

Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 118.0.2088.46
    ✘ Couldn't detect any Visual Studio or VS Build Tools instance with MSVC and SDK components. Download from https://aka.ms/vs/17/release/vs_BuildTools.exe
    ✔ rustc: 1.71.0 (8ede3aae2 2023-07-12)
    ✔ Cargo: 1.71.0 (cfd3bbd8f 2023-06-08)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 16.14.2
    - pnpm: 8.6.2
    - npm: 8.5.0

[-] Packages
    - tauri [RUST]: 1.4.0
    - tauri-build [RUST]: 1.4.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.2
    - @tauri-apps/api [NPM]: 1.4.0 (outdated, latest: 1.5.1)
    - @tauri-apps/cli [NPM]: 1.4.0 (outdated, latest: 1.5.5)

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

Stack trace

No response

Additional context

No response

@qu1ck qu1ck added status: needs triage This issue needs to triage, applied to new issues type: bug labels Oct 21, 2023
@nehaal10
Copy link

can you assign this bug to me.

@qu1ck
Copy link
Author

qu1ck commented Dec 14, 2023

Any update here? This should be a very easy fix.

amrbashir added a commit to tauri-apps/plugins-workspace that referenced this issue Dec 15, 2023
lucasfernog pushed a commit to tauri-apps/plugins-workspace that referenced this issue Dec 19, 2023
* fix(core/dialog): reconstruct path using appropriate separator

ref: tauri-apps/tauri#8074

* Reference original issue [skip ci]
@qu1ck
Copy link
Author

qu1ck commented Dec 19, 2023

Thanks for the fix, can it be backported to v1?

@FabianLars
Copy link
Member

That already happened. just waiting for the next v1 patch

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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