fix(dockview-core): recompute target location after popout single-panel move (#1004)#1287
Merged
Merged
Conversation
…el move (#1004) When a single-panel popout group is dragged back into the dock as a panel (not as the whole group), removing the popout group can cascade-remove the empty reference group it left behind in the main grid. The popout branch of moveGroupOrPanel was computing the destination grid location before that cascade-removal, so the index was off by one for any drop target after the original slot — and at the far edge it threw "Invalid index" from BranchNode.addChild, losing the panel. Recompute targetLocation from destinationGroup.element after the source group is removed, mirroring the existing pattern at the grid-source path in the same function. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fixes #1004.
When a single-panel popout window's panel was dragged back into the main dock at an extremity drop target (left/right/top/bottom of a neighbor group), the panel either landed at the wrong grid position or threw
Invalid indexat the far edge, losing the panel.Root cause — popping out a single-panel group leaves an empty, invisible reference group in the main grid. The popout branch of
moveGroupOrPanel(packages/dockview-core/src/dockview/dockviewComponent.ts) computedtargetLocationbefore removing the popout group; that removal cascades throughdoRemoveGroupto delete the empty reference group too, shifting every following grid index down by one. The staletargetLocationwas then passed tocreateGroupAtLocation, producing the wrong index (or aBranchNode.addChild: Invalid indexthrow at the far edge — matching the reporter's stack trace exactly).Fix — recompute
targetLocationfromdestinationGroup.elementafterdoRemoveGroup(sourceGroup), mirroring the existing pattern a few lines below in the grid-source branch (// after deleting the group we need to re-evaulate the ref location).Test plan
issue #1004: panel from single-panel popout lands at correct index past original slot— drops the panel right ofpanel_3(the neighbor following the original popout slot) and asserts grid order[panel_1, panel_3, panel_2, panel_4]. Confirmed to fail on the unpatched code with the panel ending up at the far right.issue #1004: panel from single-panel popout dropped past far edge does not throw— drops past the right-most neighbor. Confirmed to throwInvalid indexatBranchNode.addChildon the unpatched code (matches reporter's stack trace).popout groupdescribe block passes (25 tests).dockviewComponent.spec.tssuite: 195 passing on this branch vs. 193 on master (the +2 are the new tests). The 1 unrelated pre-existing failure (issue 1020) fails identically on master.🤖 Generated with Claude Code