Skip to content

Commit

Permalink
fix: new folder dialog not updating content (fluxxcode#187)
Browse files Browse the repository at this point in the history
* Fix create directory dialog not updating content

* Fix clippy errors

* Fix rustfmt errors
  • Loading branch information
fluxxcode authored and hacknus committed Nov 18, 2024
1 parent a62acb5 commit 59f539d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/file_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2066,8 +2066,6 @@ impl FileDialog {
should_return = true;
}
}

self.ui_update_create_directory_dialog(ui);
},
);
} else {
Expand All @@ -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);
}
});
}
});
Expand Down Expand Up @@ -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<DirectoryEntry> {
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`,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 59f539d

Please sign in to comment.