fix(dock): fix InsertChild move semantics and improve test quality

This commit is contained in:
2026-03-28 14:57:52 +09:00
parent e69e071ce2
commit b3d753fd08
3 changed files with 22 additions and 10 deletions

View File

@@ -74,7 +74,17 @@ public partial class DockGroupNode : DockNode
int oldIndex = _children.IndexOf(node);
if (oldIndex == index) return;
_children.Move(oldIndex, index);
// ObservableCollection.Move(oldIndex, newIndex) requires newIndex < Count.
// If index is Count, we move it to the last position (Count - 1).
int targetIndex = index;
if (targetIndex >= _children.Count)
{
targetIndex = _children.Count - 1;
}
if (oldIndex == targetIndex) return;
_children.Move(oldIndex, targetIndex);
return;
}

View File

@@ -414,7 +414,7 @@ public sealed partial class DockLayout : Control
/// Applies the tree mutation for a drop operation.
/// </summary>
/// <returns>True if the mutation was applied; otherwise, false.</returns>
private bool TryApplyDropMutation(DockPanelNode targetNode, DockPanelNode sourceNode, object item, DockPosition position)
internal bool TryApplyDropMutation(DockPanelNode targetNode, DockPanelNode sourceNode, object item, DockPosition position)
{
if (position == DockPosition.Center)
{