[fix]: tweak mouse interaction logic in draggable::flex_row
Some checks failed
/ clippy (push) Failing after 12m49s
/ test (push) Failing after 7m12s

We need to show the content interaction first, unless dragging, and by
default uses no interaction so developer can choose which to really show.
This commit is contained in:
Chris Cochrun 2026-05-05 11:29:13 -05:00
parent 11739283f8
commit f7d6b6be96

View file

@ -237,6 +237,7 @@ where
clip: bool,
drag_lift: f32,
animation_duration: Duration,
mouse_interaction: mouse::Interaction,
on_reorder: Box<dyn Fn(Vec<Key>) -> Message + 'a>,
keys: Vec<Key>,
locked: Vec<bool>,
@ -257,6 +258,7 @@ where
clip: false,
drag_lift: DEFAULT_DRAG_LIFT,
animation_duration: DEFAULT_ANIMATION_DURATION,
mouse_interaction: mouse::Interaction::None,
on_reorder: Box::new(on_reorder),
keys: Vec::new(),
locked: Vec::new(),
@ -300,6 +302,11 @@ where
self
}
pub fn mouse(mut self, mouse_interaction: mouse::Interaction) -> Self {
self.mouse_interaction = mouse_interaction;
self
}
/// Leave disabled for dragged item to visibly lift above the row.
pub fn clip(mut self, clip: bool) -> Self {
self.clip = clip;
@ -809,19 +816,8 @@ where
return mouse::Interaction::Grabbing;
}
if let Some(cursor_pos) = cursor.position()
&& self
.locked
.iter()
.zip(layout.children())
.any(|(locked, child_layout)| {
!*locked && child_layout.bounds().contains(cursor_pos)
})
{
return mouse::Interaction::Grab;
}
self.children
let Some(interaction) = self
.children
.iter()
.zip(&tree.children)
.zip(layout.children())
@ -835,7 +831,19 @@ where
)
})
.max()
.unwrap_or_default()
else {
if let Some(cursor_pos) = cursor.position()
&& self.locked.iter().zip(layout.children()).any(
|(locked, child_layout)| {
!*locked && child_layout.bounds().contains(cursor_pos)
},
)
{
return self.mouse_interaction;
}
return mouse::Interaction::None;
};
interaction
}
fn draw(