Skip to content

Commit

Permalink
fix(core/dialog): reconstruct path using appropriate separator, closes
Browse files Browse the repository at this point in the history
…#8074 (#8408)

* fix(core/dialog): reconstruct path using appropraite separator, closes #8074

* Update dialog-window-forward-slash.md

* Update dialog.rs

* Update core/tauri/src/endpoints/dialog.rs

---------

Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
  • Loading branch information
amrbashir and lucasfernog authored Dec 19, 2023
1 parent 9b230de commit 50a3d17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/dialog-window-forward-slash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri': 'patch:bug'
---

On Windows, fix `open` dialog `defaultPath`, when invoked from JS, not working if the path uses forward slash (`/`)
2 changes: 2 additions & 0 deletions core/tauri/src/endpoints/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ fn set_default_path(
mut dialog_builder: FileDialogBuilder,
default_path: PathBuf,
) -> FileDialogBuilder {
// we need to adjust the separator on Windows: https://github.com/tauri-apps/tauri/issues/8074
let default_path: PathBuf = default_path.components().collect();
if default_path.is_file() || !default_path.exists() {
if let (Some(parent), Some(file_name)) = (default_path.parent(), default_path.file_name()) {
if parent.components().count() > 0 {
Expand Down

0 comments on commit 50a3d17

Please sign in to comment.