Fix #7275: Preserve export selection on batched double-clicks

This commit is contained in:
makesomethingshit
2026-11-14 12:39:11 -08:00
committed by dotCooCoo
parent a05dca2e9d
commit 990a80aad8
2 changed files with 38 additions and 1 deletions
@@ -623,8 +623,14 @@ fn edit_artboard_name(
if response.double_clicked() {
*editing = Some((index, name.into(), true));
ui.ctx().request_repaint();
// If both releases arrived this frame, the first click did not toggle the row.
// Otherwise, undo the toggle from the first click on this caption.
return !ui.input(|input| {
input.events.iter().filter(|event| {
matches!(event, egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, .. } if rect.contains(*pos))
}).nth(1).is_some()
});
}
// A double-click toggles twice, preserving the checked state while opening the editor.
response.clicked()
}
}
@@ -1320,6 +1320,37 @@ fn the_dialog_builds_the_preset_list_again_only_when_the_presets_change() {
assert_eq!(mine["settings"]["formats"][0]["format"], "pdf", "{list}");
}
/// #7275: a double-click on an artboard name enters rename without leaving Export for Screens.
#[test]
fn same_frame_artboard_double_click_keeps_export_selection() {
for view in ["grid", "list"] {
for checked in [true, false] {
let (mut app, _) = app(2, true);
open(&mut app);
set(&mut app, "view", json!(view));
let mut h = ScreensFrame::new();
let out = h.settle(&mut app);
let name = app.session.active().unwrap().doc.artboards[0].name.clone();
let at = screen_text_at(&out, &format!("1 {name}"));
if !checked {
h.click(&mut app, at);
h.time += 1.0;
h.settle(&mut app);
}
let before = field(&app, "boards");
h.frame(&mut app, vec![egui::Event::PointerMoved(at)]);
let events = [true, false, true, false]
.into_iter()
.map(|pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() })
.collect();
h.frame(&mut app, events);
h.settle(&mut app);
assert!(h.ctx.egui_wants_keyboard_input(), "{view}, checked={checked}");
assert_eq!(field(&app, "boards"), before, "{view}, checked={checked}");
}
}
}
/// #7275: a double-click on an artboard name enters rename without leaving Export for Screens.
#[test]
fn switching_export_tabs_commits_an_artboard_name() {