pick select: a Prototype-tab press clears the pick like any canvas press

A press on a connection handle or noodle returns from the canvas input before the ordinary press reset, so the pick (and keyboard box) stayed up. Clear them on that press too.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Trevor BrownandClaude Fable 5.1 committed 2026-11-05 17:32:30 -05:00
1 parent ce5158e2ce
commit 49d1e2e31c
2 files changed
+29

No files matched your search

+10
View File
@@ -140,6 +140,14 @@ fn import_dropped(app: &mut FigApp, ctx: &egui::Context, hover_pos: Option<egui:
}
}
/// A press ends the keyboard selection box and pick select.
fn end_keyboard_box(app: &mut FigApp, ctx: &egui::Context) {
if ctx.input(|i| i.pointer.any_pressed()) {
app.ui.key_box = None;
app.ui.pick = None;
}
}
/// The pointer and keys on the canvas. False when something on it with a cursor of its own has
/// the pointer (a comment pin, a ruler guide, a gradient or padding handle): the tool's cursor
/// then doesn't show.
@@ -147,6 +155,8 @@ pub(super) fn input(app: &mut FigApp, ui: &mut Ui, resp: &egui::Response) -> boo
if crate::proto_canvas::input(app, ui, resp) {
// A prototype gesture is a press on the canvas too: the Pages list gives up the keyboard.
app.ui.pages_focus = None;
// And it ends the keyboard selection box and pick select, as any canvas press does.
end_keyboard_box(app, ui.ctx());
return true;
}
let ctx = ui.ctx().clone();
@@ -311,3 +311,22 @@ fn tab_switches_the_selection_box_to_pick_select() {
assert!(u.app.session.selection().is_empty(), "nothing selected in the new document");
assert!(u.app.ui.pick.is_none());
}
/// A press on a prototype connection handle is a press on the canvas too: it ends pick select
/// like any other canvas press, rather than leaving the pink outline up.
#[test]
fn a_prototype_handle_press_ends_pick_select() {
let (mut u, a, _) = setup();
u.app.run("select.set", json!({"ids": [a]}));
press(&mut u, Key::F8, Modifiers::NONE);
press(&mut u, Key::Tab, Modifiers::NONE);
assert_eq!(u.app.picked(), Some(a));
u.app.ui.right_tab = crate::RightTab::Prototype;
u.frame(vec![]);
assert_eq!(u.app.picked(), Some(a), "still picking in the Prototype tab");
let b = u.app.session.doc().unwrap().world_bounds(a).unwrap();
let handle = u.app.to_screen(b.x1, (b.y0 + b.y1) / 2.0) + egui::vec2(11.0, 0.0);
u.button(handle, true);
u.button(handle, false);
assert!(u.app.ui.pick.is_none(), "the handle press ends pick select");
}