Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: new folder dialog not updating content #187

Merged
merged 4 commits into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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