From 205fb12075b6d712d83ada03a3c264f56c46c930 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Tue, 10 Nov 2026 08:06:04 -0500 Subject: [PATCH] Present mode: a click on the draft's own pin keeps the typed draft (#2209) The pin isn't interactable, so the click fell through and started a new draft. Review item on #2211. Co-Authored-By: Claude Opus 5.5 Model-Effort: Opus 5.5 drove and wrote (review fix, no brief) --- crates/ui-egui/src/canvas/comments.rs | 5 ++++- crates/ui-egui/src/comments_tests.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas/comments.rs b/crates/ui-egui/src/canvas/comments.rs index b7410f9c6..1026ea47c 100644 --- a/crates/ui-egui/src/canvas/comments.rs +++ b/crates/ui-egui/src/canvas/comments.rs @@ -1241,8 +1241,11 @@ pub fn presenter(app: &mut FigApp, ctx: &egui::Context, frame: NodeId, place: cr // presented point back to the frame as designed. let frame_rect = place.rect(fb).intersect(clip); let click = ctx.input(|i| if i.pointer.primary_clicked() { i.pointer.interact_pos() } else { None }); + // The draft's own pin isn't interactable, so a click on it would start a new draft and lose + // the typed text: it is left alone. + let draft_pin = app.ui.comments.draft.as_ref().map(|(x, y, _)| pin_rect(to_screen((*x, *y)))); if clicked.is_none() - && let Some(q) = click.filter(|q| frame_rect.contains(*q)) + && let Some(q) = click.filter(|q| frame_rect.contains(*q) && !draft_pin.is_some_and(|r| r.contains(*q))) && ctx.layer_id_at(q).is_none_or(|l| l.order == egui::Order::Background) { let pt = place.page(q); diff --git a/crates/ui-egui/src/comments_tests.rs b/crates/ui-egui/src/comments_tests.rs index f97f4f0a4..f8d73f0d7 100644 --- a/crates/ui-egui/src/comments_tests.rs +++ b/crates/ui-egui/src/comments_tests.rs @@ -307,6 +307,18 @@ fn a_click_in_the_presenters_comment_mode_adds_a_comment_on_the_frame() { assert!(u.app.ui.present.is_some()); } +#[test] +fn a_click_on_the_presenters_draft_pin_keeps_the_typed_draft() { + let (mut u, _, _, frame_min) = present_comment_mode(); + let at = frame_min + vec2(120.0, 90.0); + click(&mut u, at); + u.frame(vec![Event::Text("typed".into())]); + // The pin's body sits above and right of the point it marks. + click(&mut u, at + vec2(6.0, -6.0)); + let draft = u.app.ui.comments.draft.clone(); + assert_eq!(draft.as_ref().map(|d| d.2.as_str()), Some("typed"), "the draft stays open with its text: {draft:?}"); +} + #[test] fn a_click_off_the_frame_in_the_presenters_comment_mode_adds_no_draft() { let (mut u, _, _, frame_min) = present_comment_mode();