From 935607fff6826d90e7a5bf6bfa5f64b59e87db47 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 23 Nov 2026 07:12:08 +0700 Subject: [PATCH] ui-contract: a drop on a grid's group header lands first in its group, now that grid places count the header rows --- crates/ui-contract/src/contract/items/drag.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/ui-contract/src/contract/items/drag.rs b/crates/ui-contract/src/contract/items/drag.rs index 43ad4e6f2..db7d1e6ee 100644 --- a/crates/ui-contract/src/contract/items/drag.rs +++ b/crates/ui-contract/src/contract/items/drag.rs @@ -74,6 +74,7 @@ fn drop_spot( layout: &dyn ItemLayout, outline: &dyn craft_behavior::NavOutline, len: &dyn Fn() -> usize, + section_stop: &dyn Fn(usize) -> bool, xf: Option, (rect, offset, rtl): (Rect, ScrollPos, bool), groups: Option, @@ -101,6 +102,11 @@ fn drop_spot( let parent = gap.parent; return Some(Spot { over, insert: gap.insert, parent, mark: gap.mark.mapped(to_screen) }); } + // A section row across a row-wise layout (a grid's group header) starts its group: a drop on it lands first in + // the group. + if across && section_stop(over) { + return Some(Spot { over, insert: over + 1, parent: None, mark: DropMark::Into(Rect::from_min_max(to_screen(row.min), to_screen(row.max))) }); + } // The gap around the one row the layout hit. `gap_at` works in physical coordinates, so across a row under // right-to-left the physical end is the earlier place in reading order. let at = if past && across { Pos2::new(if rtl { row.min.x } else { row.max.x }, row.center().y) } else { at }; @@ -603,7 +609,7 @@ impl ItemsHooks<'_, '_, C> { return None; } let outline = Outline::new(self.source); - drop_spot(layout, &outline, &|| self.source.len(), self.xf, (rect, offset, rtl), groups, at) + drop_spot(layout, &outline, &|| self.source.len(), &|at| self.source.section_stop(at), self.xf, (rect, offset, rtl), groups, at) } /// Whether a drop inside the group row `parent` would put a dragged item inside itself.