diff --git a/CHANGELOG.md b/CHANGELOG.md index 84dc174..c2be43d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/file_dialog.rs b/src/file_dialog.rs index de5ec42..e248442 100644 --- a/src/file_dialog.rs +++ b/src/file_dialog.rs @@ -58,7 +58,12 @@ impl FileDialog { /// * Windows /// * Mac pub fn set_directory>(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 }