Skip to content

Commit

Permalink
mouse_area: Fix on_drag behavior without on_release
Browse files Browse the repository at this point in the history
Mouse/touch release events should end the drag even if there's not an
`on_release` callback.

This was causing pop-os/cosmic-comp#1071.
  • Loading branch information
ids1024 authored and mmstick committed Jan 28, 2025
1 parent 82b87f9 commit f1a1242
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions widget/src/mouse_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,11 @@ fn update<Message: Clone, Theme, Renderer>(
}
}

if let Some(message) = widget.on_release.as_ref() {
if let Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
| Event::Touch(touch::Event::FingerLifted { .. }) = event
{
state.drag_initiated = None;
if let Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
| Event::Touch(touch::Event::FingerLifted { .. }) = event
{
state.drag_initiated = None;
if let Some(message) = widget.on_release.as_ref() {
shell.publish(message.clone());

return event::Status::Captured;
Expand Down

0 comments on commit f1a1242

Please sign in to comment.