Skip to content

Commit c1ebd53

Browse files
committed
fix(table): prevent double-toggle on checkbox/multiselect click
Button1Pressed and Button1Clicked both fired for a single physical click, causing ToggleRowSelection to run twice and the else branch to clear _selectedRowIndices before the click event arrived. Guard all multi-select logic behind Button1Clicked; Button1Pressed now only moves the cursor row.
1 parent 0d288c9 commit c1ebd53

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

SharpConsoleUI/Controls/TableControl/TableControl.Mouse.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,17 @@ public bool ProcessMouseEvent(MouseEventArgs args)
204204

205205
// Click on data row
206206
int rowIdx = GetRowIndexAtY(args.Position.Y);
207+
bool isClick = args.HasFlag(MouseFlags.Button1Clicked);
207208
if (rowIdx >= 0)
208209
{
209-
// Multi-select: Ctrl+Click toggles, Shift+Click extends range, checkbox click toggles
210-
if (_multiSelectEnabled && args.HasFlag(MouseFlags.ButtonCtrl))
210+
// Multi-select toggling only on Button1Clicked to avoid
211+
// double-toggle from Button1Pressed + Button1Clicked pair
212+
if (!isClick)
213+
{
214+
// Button1Pressed: just move cursor, don't touch multi-select state
215+
SetSelectedRow(rowIdx);
216+
}
217+
else if (_multiSelectEnabled && args.HasFlag(MouseFlags.ButtonCtrl))
211218
{
212219
ToggleRowSelection(rowIdx);
213220
SetSelectedRow(rowIdx);

0 commit comments

Comments
 (0)