Skip to content

Commit

Permalink
fix(FileDialog): fallback to current dir if path is empty (#89)
Browse files Browse the repository at this point in the history
* fix(FileDialog): fallback to current dir if path is empty

ref: tauri-apps/tauri#5564

* changelog entry

* Update file_dialog.rs

* fallback to `None`

* fmt
  • Loading branch information
amrbashir authored Nov 9, 2022
1 parent 7a0ab7a commit b9c04e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change Log

## Unreleased
- fix(FileDialog::set_directory): fallback to default if path is empty

## 0.9.0
- feat: customize button text, Close #74
Expand Down
7 changes: 6 additions & 1 deletion src/file_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ impl FileDialog {
/// * Windows
/// * Mac
pub fn set_directory<P: AsRef<Path>>(mut self, path: P) -> Self {
self.starting_directory = Some(path.as_ref().into());
let path = path.as_ref();
if path.to_str().map(|p| p.is_empty()).unwrap_or(false) {
self.starting_directory = None;
} else {
self.starting_directory = Some(path.into());
}
self
}

Expand Down

0 comments on commit b9c04e8

Please sign in to comment.