mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-16 02:15:34 -05:00
fix(desktop): keep the plate list selection in sync with the header arrows
Navigating plates from the plate view header (or Ctrl+Left/Right) changed the plate without updating the plate list, so its highlighted row pointed at a different plate. Select, focus and scroll to the current plate's row whenever the current plate changes, guarded so the list doesn't reload it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
63771b0029
commit
c58ae6f9e1
1 file changed
+22
-2
@@ -1025,13 +1025,32 @@ namespace OpenNest.Forms
|
||||
|
||||
private void FirePlateChanged(bool updateListView = true)
|
||||
{
|
||||
if (updateListView && PlateManager.CurrentIndex < platesListView.Items.Count)
|
||||
platesListView.Items[PlateManager.CurrentIndex].Selected = true;
|
||||
if (updateListView)
|
||||
SelectCurrentPlateInList();
|
||||
|
||||
UpdatePlateHeader();
|
||||
PlateChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void SelectCurrentPlateInList()
|
||||
{
|
||||
var index = PlateManager.CurrentIndex;
|
||||
if (index < 0 || index >= platesListView.Items.Count)
|
||||
return;
|
||||
|
||||
var item = platesListView.Items[index];
|
||||
if (item.Selected)
|
||||
return;
|
||||
|
||||
// Guarded so the list's own SelectedIndexChanged doesn't reload the plate.
|
||||
var wasUpdating = updatingPlateList;
|
||||
updatingPlateList = true;
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
item.EnsureVisible();
|
||||
updatingPlateList = wasUpdating;
|
||||
}
|
||||
|
||||
private void UpdatePlateHeader()
|
||||
{
|
||||
var plate = PlateManager.CurrentPlate;
|
||||
@@ -1445,6 +1464,7 @@ namespace OpenNest.Forms
|
||||
{
|
||||
PlateView.Plate = PlateManager.CurrentPlate;
|
||||
PlateView.ZoomToFit();
|
||||
SelectCurrentPlateInList();
|
||||
UpdatePlateHeader();
|
||||
UpdateRemovePlateButton();
|
||||
PlateChanged?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
Reference in new issue
Block a user