Fixed folder picker appearing behind profile window
Moorly CI / windows-build (push) Successful in 3m43s
Moorly CI / linux-build (push) Successful in 4m12s

This commit is contained in:
Squid committed 2026-11-17 21:02:58 +01:00
1 parent ce917ced9f
commit fca5bb4e93
1 file changed
+55 -18
+55 -18
View File
@@ -9161,8 +9161,7 @@ fn profiles_panel(state: &Moorly, window: window::Id, show_add: bool) -> Element
|| state.transfer.is_some()
|| state.trash_open
|| state.confirm_delete
|| state.confirm_purge_trash
|| state.dir_picker.is_some();
|| state.confirm_purge_trash;
if !show_add && !dialog_open {
return stack![base].into();
@@ -9178,9 +9177,7 @@ fn profiles_panel(state: &Moorly, window: window::Id, show_add: bool) -> Element
.width(Length::Fill)
.height(Length::Fill),
)
.on_press(if state.dir_picker.is_some() {
Message::CancelDirectoryPicker
} else if state.confirm_purge_trash {
.on_press(if state.confirm_purge_trash {
Message::CancelPurgeTrash
} else if state.trash_open {
Message::CloseTrash
@@ -9439,19 +9436,6 @@ fn profiles_panel(state: &Moorly, window: window::Id, show_add: bool) -> Element
layers = layers.push(dialog_layer);
}
if let Some(picker) = &state.dir_picker {
let dialog = directory_picker_view(picker);
let dialog = mouse_area(dialog).on_press(Message::Ignore);
let dialog_layer = container(dialog)
.width(Length::Fill)
.height(Length::Fill)
.align_x(Alignment::Center)
.align_y(Alignment::Center);
layers = layers.push(dialog_layer);
}
layers.into()
}
@@ -12663,11 +12647,13 @@ fn view(state: &Moorly, window: window::Id) -> Element<'_, Message> {
let palette = command_palette_layer(state, window);
let dialog = profile_dialog_layer(state, window);
let terminal_menu = terminal_context_menu(state, window);
let dir_picker = state.dir_picker.as_ref();
if state.notifications.is_empty()
&& palette.is_none()
&& dialog.is_none()
&& terminal_menu.is_none()
&& dir_picker.is_none()
{
return content;
}
@@ -12711,6 +12697,27 @@ fn view(state: &Moorly, window: window::Id) -> Element<'_, Message> {
root = root.push(menu);
}
// The directory picker is opened from the profile dialog, so it belongs
// above it instead of inside the Settings page layers below.
if let Some(picker) = dir_picker {
let dialog = mouse_area(directory_picker_view(picker)).on_press(Message::Ignore);
let backdrop = mouse_area(
container(space::horizontal())
.width(Length::Fill)
.height(Length::Fill),
)
.on_press(Message::CancelDirectoryPicker);
root = root.push(backdrop);
root = root.push(
container(dialog)
.width(Length::Fill)
.height(Length::Fill)
.align_x(Alignment::Center)
.align_y(Alignment::Center),
);
}
root.width(Length::Fill).height(Length::Fill).into()
}
@@ -15673,6 +15680,36 @@ start_path = "/tmp"
std::fs::remove_dir_all(&root).unwrap();
}
#[test]
fn directory_picker_is_above_the_profile_dialog() {
let stamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_nanos();
let root = std::env::temp_dir().join(format!("moorly-layer-test-{stamp}"));
let child = root.join("child");
std::fs::create_dir_all(&child).unwrap();
let mut state = state();
window_state_mut(&mut state).active_tab = Some(Tab::Settings);
state.profile_dialog = Some(super::ProfileDraft::new(0));
state.dir_picker = Some(super::DirPicker::open(
root.clone(),
false,
super::PickerTarget::StartPath,
));
let mut ui = iced_test::simulator(super::view(&state, test_window()));
ui.click("child").unwrap();
assert!(
ui.into_messages()
.any(|message| matches!(message, Message::DirPickerEnter(_)))
);
std::fs::remove_dir_all(&root).unwrap();
}
#[test]
fn adding_a_folder_selects_it() {
let mut state = state();