Skip to content

Fix default dockable split#994

Merged
wieslawsoltes merged 3 commits intomasterfrom
fix/issue-936-defaultdockable-split
Jan 21, 2026
Merged

Fix default dockable split#994
wieslawsoltes merged 3 commits intomasterfrom
fix/issue-936-defaultdockable-split

Conversation

@wieslawsoltes
Copy link
Owner

PR summary: issue 936 default dockable split fix

Summary

Fixes a layout serialization failure where RootDock.DefaultDockable could point
to a replaced dock after a global split operation. The fix keeps the default
pointer aligned with the new split container and adds a regression test.

Findings

  • A global split that replaces a dock in its owner (via SplitToDock) updates
    ActiveDockable but left DefaultDockable pointing at the old dock instance.
  • The stale default is serialized, so deserialization reconstructs a layout with
    an orphaned DefaultDockable reference, which can break load or result in an
    invalid root state.
  • The issue is visible with a flat root layout (single visible dockable) where
    a split wraps the dock in a new ProportionalDock, leaving the root default
    pointed at the pre-split dock.

Implementation

  • FactoryBase.SplitToDock now detects when the owner default is the dock being
    replaced and retargets DefaultDockable to the new split layout.
  • The change is limited to the replacement path (non-optimized branch) to avoid
    altering behavior when the owner container is reused.
var wasDefaultDockable = ownerDock.DefaultDockable == dock;
...
ownerDock.ActiveDockable = layout;
if (wasDefaultDockable)
{
    ownerDock.DefaultDockable = layout;
}
  • Added a headless test to assert both ActiveDockable and DefaultDockable
    point to the new layout after a split.

Usage guide

  • No API changes are required. Update to a build that includes this fix.
  • If you rely on RootDock.DefaultDockable to restore the main layout on load,
    it will now follow split replacements automatically.
  • To verify in DockMvvmSample, use the issue repro steps: perform a global
    split on the root, save the layout, then reload. The layout should deserialize
    correctly and the root default should match the split container.
  • If you implement custom split logic outside FactoryBase.SplitToDock, mirror
    this behavior by updating DefaultDockable when a dock is replaced.

Tests

  • dotnet test

Fixes #936

@wieslawsoltes wieslawsoltes changed the title Fix/issue 936 defaultdockable split Fix default dockable split Jan 21, 2026
@wieslawsoltes wieslawsoltes merged commit c12f63a into master Jan 21, 2026
4 checks passed
@wieslawsoltes wieslawsoltes deleted the fix/issue-936-defaultdockable-split branch January 21, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RootDock.DefaultDockable is not updated after a global SplitToDock operation, causing deserialization failure

1 participant