Skip to content

fix: minimise a maximised item before removing, replacing or dragging items around it - #24

Merged
OfekShilon merged 2 commits into
compiler-explorer:ce-mainfrom
OfekShilon:fix/maximised-remove-and-drop
Nov 14, 2026
Merged

OfekShilon merged 2 commits into
compiler-explorer:ce-mainfrom
OfekShilon:fix/maximised-remove-and-drop

Conversation

@OfekShilon

Copy link
Copy Markdown
Member

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:

  • Removing a sibling (or any item in a row/column containing the maximised item) shrank it to its share of the row while it stayed maximised. If the removal collapsed its row into a column, the column was corrupted on minimise. CE does this from code: deleting an open file from a maximised Tree pane closes the file's editor.
  • Closing the maximised item left _maximisedItem pointing at the destroyed item, so toConfig() still saved maximisedItemId (TypeError: Cannot read property 'toggleMaximise' of undefined compiler-explorer#2056, which CE works around on load). Minimising afterwards re-inserted the destroyed element.
  • Dropping on the maximised stack's edge, a hidden sibling's edge, or the layout's edge shrank it or moved its element into the wrong container.
  • Dragging from a drag source inside a maximised item (CE's "add pane" buttons) kept it maximised during the drag, so the drop targets were hidden behind it and the new item landed in a hidden stack.
  • Maximising a second item via the API left the first one's isMaximised set, and toggling it later threw Id not found.

Changes

  • _minimiseMaximisedDescendant moves from RowOrColumn to AbstractContentItem. It's now also called at the top of removeChild and replaceChild (both the base and RowOrColumn versions).
  • DragSource._onDragStart minimises the maximised item, as Tab._onDragStart already does.
  • _$maximiseItem minimises the previous item with toggleMaximise() so its flag is reset.

Closing a tab inside a maximised stack keeps the stack maximised.

Tests

test/maximise-tests.js gains 11 tests:

  • 10 cover the cases above. Each one fails on 1.6.4 and passes with this change.
  • 1 checks that closing one tab of a maximised stack keeps it maximised.

npm test passes, including typecheck.

🤖 Generated with Claude Code

… 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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread src/js/LayoutManager.js Resolved
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the changes to maximised-item removal, replacement, and drag handling.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@OfekShilon
OfekShilon merged commit e35a3b4 into compiler-explorer:ce-main Nov 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants