fix(ui): select task on left-click even when reorder is disabled
The tunnel pointer handler returned early when CanReorder was false, so clicking a row in smart/virtual lists never updated the details pane. Select first, then bail out of the drag path; also skip drag initialisation on nested buttons so the done-toggle click still fires.
This commit is contained in:
@@ -15,8 +15,6 @@ public partial class TasksIslandView : UserControl
|
|||||||
public TasksIslandView()
|
public TasksIslandView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
// Tunnel handler runs BEFORE Button's class handler so we can start a drag
|
|
||||||
// without the Button first marking the event as handled.
|
|
||||||
AddHandler(PointerPressedEvent, OnTunnelPointerPressed, RoutingStrategies.Tunnel);
|
AddHandler(PointerPressedEvent, OnTunnelPointerPressed, RoutingStrategies.Tunnel);
|
||||||
DataContextChanged += (_, _) =>
|
DataContextChanged += (_, _) =>
|
||||||
{
|
{
|
||||||
@@ -27,14 +25,25 @@ public partial class TasksIslandView : UserControl
|
|||||||
|
|
||||||
private async void OnTunnelPointerPressed(object? sender, PointerPressedEventArgs e)
|
private async void OnTunnelPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||||
{
|
{
|
||||||
if (DataContext is not TasksIslandViewModel vm || !vm.CanReorder) return;
|
if (DataContext is not TasksIslandViewModel vm) return;
|
||||||
if (e.Source is not Visual src) return;
|
if (e.Source is not Visual src) return;
|
||||||
|
|
||||||
var button = src as Button ?? src.FindAncestorOfType<Button>();
|
var button = src as Button ?? src.FindAncestorOfType<Button>();
|
||||||
if (button?.DataContext is not TaskRowViewModel row) return;
|
if (button?.DataContext is not TaskRowViewModel row) return;
|
||||||
if (row.IsRunning) return;
|
|
||||||
if (!e.GetCurrentPoint(button).Properties.IsLeftButtonPressed) return;
|
if (!e.GetCurrentPoint(button).Properties.IsLeftButtonPressed) return;
|
||||||
|
|
||||||
|
// Select now so the details pane updates whether the gesture becomes a click or a drag.
|
||||||
|
// (Button.Click doesn't fire once DoDragDropAsync captures the pointer.)
|
||||||
|
vm.SelectedTask = row;
|
||||||
|
|
||||||
|
// If the click landed on a nested Button (e.g. the done-toggle checkbox or star),
|
||||||
|
// don't start a drag — that would capture the pointer and swallow the inner Click.
|
||||||
|
var nestedInsideButton = button.Parent is Visual parentVisual
|
||||||
|
&& parentVisual.FindAncestorOfType<Button>() is not null;
|
||||||
|
if (nestedInsideButton) return;
|
||||||
|
|
||||||
|
if (!vm.CanReorder || row.IsRunning) return;
|
||||||
|
|
||||||
var data = new DataTransfer();
|
var data = new DataTransfer();
|
||||||
data.Add(DataTransferItem.Create(TaskRowFormat, row.Id));
|
data.Add(DataTransferItem.Create(TaskRowFormat, row.Id));
|
||||||
try
|
try
|
||||||
@@ -133,11 +142,18 @@ public partial class TasksIslandView : UserControl
|
|||||||
if (source is null || source.IsRunning) return;
|
if (source is null || source.IsRunning) return;
|
||||||
|
|
||||||
var placeBelow = e.GetPosition(b).Y > b.Bounds.Height / 2;
|
var placeBelow = e.GetPosition(b).Y > b.Bounds.Height / 2;
|
||||||
|
|
||||||
|
// Clear the 6px drop-hint spacer BEFORE the move so the reorder animates
|
||||||
|
// into its truly-final layout in one step (otherwise the row lands in the
|
||||||
|
// gap, then the gap collapses and everything shifts up a second time).
|
||||||
|
vm.ClearDropHints();
|
||||||
|
|
||||||
await vm.ReorderAsync(source, target, placeBelow);
|
await vm.ReorderAsync(source, target, placeBelow);
|
||||||
}
|
}
|
||||||
finally
|
catch
|
||||||
{
|
{
|
||||||
vm.ClearDropHints();
|
vm.ClearDropHints();
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user