Skip to content

[bugfix] canvas: keep selected node toolbar below the top bar (#513) - #516

Draft
yefuyou wants to merge 1 commit into
ThinkFlowLab:mainfrom
yefuyou:fix/513-toolbar-overlap
Draft

yefuyou wants to merge 1 commit into
ThinkFlowLab:mainfrom
yefuyou:fix/513-toolbar-overlap

Conversation

@yefuyou

@yefuyou yefuyou commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #513.

The floating toolbar for a selected canvas node could overlap the global top bar after dragging or viewport movement. When it overlapped the top bar, it intercepted pointer events and made global controls such as Switch project difficult or impossible to activate.

This PR fixes the product-side positioning constraint and adds regression coverage using real browser pointer interactions.

Root cause

The single-selection toolbar placement calculation did not enforce the canvas safe area's top boundary (safe.y). It relied on viewport presentation adjustment to move the toolbar below the top bar.

That reliance was insufficient: after a drag or manual pan, the toolbar could remain above the safe boundary. In the reproduced case it was positioned at approximately y=28 while the top bar extended to y=68, allowing the toolbar's hit area to intercept the project switcher.

The pointer-gesture timing explained why the browser test could pass incidentally after a later render, but the underlying product defect was the missing geometric constraint.

Fix

Clamp the single-selection toolbar's top coordinate to the safe area's top boundary:

top = Math.max(safe.y, calculatedTop)

This is a local, deterministic placement constraint. It does not depend on a later React render, delayed viewport adjustment, or a test-only workaround.

Evidence

  • Red/green unit test: the new placement test fails on the unfixed baseline (actual: 28, expected: 72) and passes with the fix.
  • Browser regression: the new canvas_toolbar_topbar.mjs test uses real mouse input and real hit-testing. It verifies the project switcher opens, the node remains selected, the node toolbar remains operable, and the viewport does not jump.
  • Reproduction of the CI timing variant: before the fix, hovering Retry before clicking reproduced the same 720 panorama pointer interception in 5/5 runs. After the fix, the variant passed 5/5.
  • CI-order regression: canvas_switch → canvas_progressive_load → canvas_toolbar_topbar passed 5 rounds (15/15 scripts) on the updated main baseline.
  • Additional coverage: en-US and zh-CN, right edge, top-left corner, repeated drags, Escape-cancelled drag, reselection, repeated rerenders, and a node dragged beneath the top bar.
  • Adjacent tests: nine related Canvas browser scripts passed, including canvas_progressive_load, created_node_focus, and canvas_text_markdown.
  • Static checks: build (including TypeScript), i18n, browser-locale, manifest, and whitespace checks passed.
  • Full unit suite: 1003 passed, 2 failed. The same two environment-related failures reproduce on clean 635666b (server environment and desktop Python discovery); no new failure was introduced relative to that baseline.
  • Independent review: PASS.

GitHub Actions on current HEAD a4efefda7d5220b8cd3a534eae1542b3531e30ca: all seven Release checks passed; DSH plugin checks and CodeQL also succeeded. This PR remains Draft.

Screenshots

Captured from real Chromium pointer interactions with synthetic canvas data. Each locale shows the overall selected-node layout, the project switcher menu opening, and the selected-node toolbar menu opening.

English UI

Selected-node toolbar layout

Switch project menu opened

Toolbar presets menu opened

简体中文 UI

选中节点后的工具栏布局

打开项目切换菜单

打开工具栏预设菜单

Known limitations

  • When a node is very close to or beneath the top bar, its toolbar may sit over the node's title strip.
  • With the composer open and an unusual pan position, the toolbar may partially overlap the composer's top edge.
  • The separate post-drag viewport jump tracked in [bug] canvas: stale post-drag presentation adjustment can jump the viewport on the next click #514 is not fixed by this PR.
  • The tests cover the reproduced and enumerated interaction paths; they do not prove every possible layout and timing combination.

Scope

This PR is limited to Canvas selection-toolbar positioning and its regression tests. It does not modify Agent Runtime, SSE, Trace export, #476, or #512.

…lowLab#513)

The single-node toolbar was anchored above the selected node without
respecting the safe area below the top bar (safe.y). Only the selection
fit kept it out of the top bar, and that fit deliberately does not run
after a drag or a manual pan; after a drag-select it is also deferred
until the next pointerdown, because pointerGesture.moved stays set after
release. The toolbar (z-index 16) then covered the top bar (z-index 12)
and intercepted clicks on Switch project. Playwright never dispatches a
pointerdown while its hit target is covered, so canvas_progressive_load
could wait the full click timeout.

Clamp the toolbar's top to safe.y in selectionPlacement, like the
multi-selection bar already does. Fitted selections already sit at
safe.y, so ordinary placement and viewport behaviour are unchanged.

Add a unit test and a real-pointer browser regression
(canvas_toolbar_topbar.mjs, gate lane) covering drag near the top,
toolbar use, a second drag, a manual pan and a project switch in en-US
and zh-CN at zoom 0.5, 1 and 1.5. Both fail on the previous revision.

Fixes ThinkFlowLab#513

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.

[bug] canvas: selected node toolbar can block Switch project after dragging

2 participants