Skip to content

fix(core): refresh default multi-canvas views after canvas reorder - #10875

Open
pujitha24 wants to merge 1 commit into
visgl:masterfrom
pujitha24:auto/issue-10602
Open

pujitha24 wants to merge 1 commit into
visgl:masterfrom
pujitha24:auto/issue-10602

Conversation

@pujitha24

@pujitha24 pujitha24 commented Oct 18, 2026 •

Copy link
Copy Markdown

Closes #10602

Background

Reordering _canvases changes the default target for views without a canvasId, but the eventManagers map kept its identity, so such views could keep viewports and controllers for the former first canvas.

Change List

  • CanvasManager: replace eventManagers map when canvas order changes
  • Unit tests

This PR was written in part with the assistance of generative AI.


Note

Low Risk
Targeted fix to multi-canvas order handling with regression tests; no auth, data, or broad API changes.

Overview
Fixes multi-canvas setups where reordering _canvases left views without a canvasId bound to the wrong canvas because CanvasManager kept the same eventManagers object when only presentation order changed.

CanvasManager now compares canvas order with _haveSameOrder and replaces the eventManagers map when order changes (even if the same EventManager instances are reused), so Deck/ViewManager see an eventManagers identity change and rebuild default-target viewports and input routing. Tests assert reordering swaps the default canvas, refreshes the left view’s event root and viewport width, and restores them when order is reverted.

Reviewed by Cursor Bugbot for commit 08772d4. Bugbot is set up for automated code reviews on this repo. Configure here.

Motivation: In multi-canvas mode the first `_canvases` entry is the default
target for views without an explicit `canvasId`. Reordering the same entries
kept the `eventManagers` map identity in CanvasManager, so ViewManager did not
rebuild and views could keep viewports/controllers bound to the former first
canvas.

Approach: CanvasManager.syncCanvasEntries now also replaces the `eventManagers`
map when the presentation order changes, which makes ViewManager rebuild its
viewports and controllers. An unchanged order still preserves map identity.

Validation: extended the `Deck#multi-canvas presentation` test in
test/modules/core/lib/deck.spec.ts to reorder canvases and check the default
canvas, event manager and viewport size. Without the src change it fails
(`eventManagers` identity unchanged); with it, it passes
(`npx vitest run --project headless test/modules/core/lib/deck.spec.ts`).
`yarn lint` passes. Full `yarn test-headless` had two unrelated failures
(loading-widget, project-glsl timeout) that passed when re-run in isolation.
Render/browser tests were not run.

Report: visgl#10602
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Changes how canvas reordering triggers viewport refresh.

The fix appears safe to merge, with a non-blocking gap in controller test coverage.

Findings

  1. P2 Controller movement remains untested ▶

Summary

CanvasManager now replaces the eventManagers map when canvas order changes, so default views rebuild against the new first canvas.

  • Views without a canvas ID follow the newly first canvas.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Canvas order changes] --> B[New eventManagers map]
  B --> C[ViewManager requests rebuild]
  C --> D[Default viewport uses new first canvas]
  C --> E[Moved controller binds to new canvas]
Loading

Reviews (1) · Last reviewed commit: "fix(core): refresh default multi-canvas ..." · Reviewed by Greptile

Comment on lines +598 to +601
expect(deck.getEventManager('left')?.getElement()).toBe(eventRootB);
expect(deck.getViewports().find(viewport => viewport.id === 'left')?.width).toBe(32);
deck.setProps({_canvases: [canvasA, canvasB]});
expect(deck.getEventManager('left')?.getElement()).toBe(eventRootA);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Controller movement remains untested

Neither view enables a controller, so this test cannot catch a controller left listening on the former canvas. getEventManager('left') reads the current canvas mapping, not the controller's event manager. Enable controller: true on the default view and check that its controller uses canvas B's event manager after reorder and canvas A's after restore.

This branch has not been deployed

No deployments
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.

fix(core): refresh default multi-canvas views after target reorder

1 participant