Repository navigation
fix: minimise a maximised item before removing, replacing or dragging items around it - #24
Merged
OfekShilon merged 2 commits intoNov 14, 2026
Conversation
… items around it Extends compiler-explorer#22, which minimised a maximised item before adding a sibling, to the other operations that move items around it. A maximised item's element lives in the root until it is minimised, so removing or replacing items in its row or column shrank it or left the layout broken, and closing it left the layout still pointing at it as maximised (compiler-explorer/compiler-explorer#2056). Rows, columns and the root now minimise a maximised descendant first. Drag sources minimise before dragging, as tabs already do, and maximising a second item now resets the first one's flag. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
A synchronous maximised listener that maximises another item can trigger infinite recursion and a RangeError because the first item's isMaximised flag is updated too late.
1 open issue
What changed in this PR
Extends the earlier sibling-addition fix to other layout operations, restoring maximised items before structural changes can disrupt their placement or state.
Changes:
- Shares descendant-minimisation logic across content items and applies it before removal and replacement.
- Restores maximised items when starting a drag source or maximising another item.
- Adds 11 regression tests covering removal, closing, dropping, dragging, and maximisation switching.
| File | Description |
|---|---|
test/maximise-tests.js |
Adds helpers and regression tests for maximised-item interactions. |
src/js/LayoutManager.js |
Uses the previous item's toggle to reset its maximisation flag. |
src/js/items/RowOrColumn.js |
Restores maximised descendants before removal; inherits the shared helper. |
src/js/items/AbstractContentItem.js |
Hosts the shared helper and invokes it before removal and replacement. |
src/js/controls/DragSource.js |
Restores the maximised item before starting an external drag. |
Review effort: Balanced
A 'maximised' listener that maximised another item recursed until it threw a RangeError, because the first item still looked unmaximised when switching to the second one minimised it. Co-authored-by: Claude Opus 5.5 <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.

Extends #22 (minimise a maximised item before adding a sibling) to the other operations that move items around a maximised item.
What broke
A maximised item's element lives in the root, with a placeholder left in its row or column, until it's minimised. On 1.6.4:
_maximisedItempointing at the destroyed item, sotoConfig()still savedmaximisedItemId(TypeError: Cannot read property 'toggleMaximise' of undefined compiler-explorer#2056, which CE works around on load). Minimising afterwards re-inserted the destroyed element.isMaximisedset, and toggling it later threwId not found.Changes
_minimiseMaximisedDescendantmoves fromRowOrColumntoAbstractContentItem. It's now also called at the top ofremoveChildandreplaceChild(both the base andRowOrColumnversions).DragSource._onDragStartminimises the maximised item, asTab._onDragStartalready does._$maximiseItemminimises the previous item withtoggleMaximise()so its flag is reset.Closing a tab inside a maximised stack keeps the stack maximised.
Tests
test/maximise-tests.jsgains 11 tests:npm testpasses, including typecheck.🤖 Generated with Claude Code