diff --git a/src/file_dialog.rs b/src/file_dialog.rs index 299ba292..9a17939f 100644 --- a/src/file_dialog.rs +++ b/src/file_dialog.rs @@ -2066,8 +2066,6 @@ impl FileDialog { should_return = true; } } - - self.ui_update_create_directory_dialog(ui); }, ); } else { @@ -2088,7 +2086,9 @@ impl FileDialog { } } - self.ui_update_create_directory_dialog(ui); + if let Some(entry) = self.ui_update_create_directory_dialog(ui) { + data.push(entry); + } }); } }); @@ -2224,14 +2224,11 @@ impl FileDialog { false } - fn ui_update_create_directory_dialog(&mut self, ui: &mut egui::Ui) { - if let Some(path) = self - .create_directory_dialog + fn ui_update_create_directory_dialog(&mut self, ui: &mut egui::Ui) -> Option { + self.create_directory_dialog .update(ui, &self.config) .directory() - { - self.process_new_folder(&path); - } + .map(|path| self.process_new_folder(&path)) } /// Selects every item inside the `directory_content` between `item_a` and `item_b`, @@ -2575,12 +2572,14 @@ impl FileDialog { } /// Function that processes a newly created folder. - fn process_new_folder(&mut self, created_dir: &Path) { + fn process_new_folder(&mut self, created_dir: &Path) -> DirectoryEntry { let mut entry = DirectoryEntry::from_path(&self.config, created_dir); self.directory_content.push(entry.clone()); self.select_item(&mut entry); + + entry } /// Opens a new modal window.