From f43a8af538a52efb86b9bbe532a08270e19a5e61 Mon Sep 17 00:00:00 2001 From: mtlcl410 <2368091+mtlcl410@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:51:24 +0800 Subject: [PATCH] M5: a right-click on a group member selects its group MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review follow-up on #4358: the secondary-click path still selected with cx.hit, which misses a group subordinate lying outside its primary's rectangle and cleared the selection, so the menu offered page actions instead of the comment's. It now uses the group-aware cx.click_hit, as the click does (ISO 32000-2 ยง12.5.6.2). Double-click editing goes through the same group-aware hit as the click since the rebase onto main, where the press owner comes from the module's hit test; the test covers both. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv --- crates/ui-egui/src/tools/comments/input.rs | 3 ++- crates/ui-egui/tests/it/comments.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/tools/comments/input.rs b/crates/ui-egui/src/tools/comments/input.rs index 6e948bcf21..ff1d42a309 100644 --- a/crates/ui-egui/src/tools/comments/input.rs +++ b/crates/ui-egui/src/tools/comments/input.rs @@ -31,7 +31,8 @@ pub(crate) fn page_input(ui: &egui::Ui, resp: &egui::Response, cx: &PageCx<'_>, && let Some(p) = pointer.filter(|p| page_rect.contains(*p)) { cv.context_at = Some((cx.page, cx.to_user(p))); - cv.selected = cx.hit(p).map(|a| (cx.page, a.index)); + // On a group subordinate, its group (the primary), so the menu offers the comment's actions. + cv.selected = cx.click_hit(p).map(|a| (cx.page, a.index)); } let gestures = Gestures { ui, resp, cx, pointer, origin, page_rect, pressed_here, over_page }; match cx.tool { diff --git a/crates/ui-egui/tests/it/comments.rs b/crates/ui-egui/tests/it/comments.rs index 3e078b6d49..dc64694db6 100644 --- a/crates/ui-egui/tests/it/comments.rs +++ b/crates/ui-egui/tests/it/comments.rs @@ -3062,4 +3062,20 @@ fn a_group_is_one_comment_in_the_panel_and_on_the_page() { let p = at(&h, 60.0, 50.0); click(&mut h, p); assert_eq!(h.state().views[0].comments.selected, Some((0, 0))); + // #4358 review: a right-click on the Circle selects the group too, so the menu is the + // comment's, and a double-click there edits the group's text, which is the Square's. + h.state_mut().views[0].comments.selected = None; + let p = at(&h, 220.0, 150.0); + h.hover_at(p); + h.run_steps(1); + h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() }); + h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() }); + h.run_steps(3); + assert_eq!(h.state().views[0].comments.selected, Some((0, 0)), "a right-click on the Circle selects its group"); + h.key_press(egui::Key::Escape); + h.run_steps(2); + h.state_mut().views[0].comments.selected = None; + crate::support::input::double_click(&mut h, p); + let composer = h.state().views[0].comments.composer.as_ref().map(|c| c.text.clone()); + assert_eq!(composer.as_deref(), Some("Primary"), "a double-click on the Circle edits its group's text"); }