Skip to content

fix(ui): an open menu keeps its place in its host when the page scrolls - #409

Merged
alexgrover merged 1 commit into
devfrom
fix/menu-follows-page-scroll
Nov 17, 2026
Merged

alexgrover merged 1 commit into
devfrom
fix/menu-follows-page-scroll

Conversation

@alexgrover

@alexgrover alexgrover commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Background

Reported on the live demo: with the timeframe menu open, scrolling the page with the mouse
wheel moves the menu away from its button. The demo is the one place where the workspace sits
inside a page that scrolls, which is why a chart that fills its page never showed it.

The dropdown menu held its anchor in viewport coordinates, taken once as the menu opened (the
pin that keeps the list still when starring a timeframe shifts the caret). Every re-placement
after a scroll put the list back at that spot on screen while the trigger scrolled away.

Menus opened at a point with openAt (context menus, the alerts list, the legend's move menu)
had a second form of it: they gave those re-placements no anchor at all, so the first scroll
sent the list to the top of the window, where a page header can hide it.

Summary

The menu's anchor is now held as an offset inside its host, for a trigger and for a point
alike. An open list keeps its place in the host:

  • a page that scrolls the host carries the list along;
  • a trigger that moves inside the host still leaves the list where it opened, as before;
  • a submenu follows its row, as before.

Nothing changes for a chart that fills its page: while the host does not move, the anchor is
the same rectangle as before.

End-to-end verification

The workspace playground, restyled into a 3200px page with the chart as a block 200px down,
in headless Chromium at 1400×800. Each menu was opened with a real click, then the page was
scrolled 120px and back with a real mouse wheel over the open list.

Check Before After
Timeframe menu, gap to its button 8 → 128px 8 → 8px
Chart style menu, gap to its button 8 → 128px 8 → 8px
Time zone menu, gap to its button 7.5 → -112.5px 7.5 → 7.5px
Chart right-click menu jumps to the window's top edge keeps its place in the chart
Time-axis menu with its submenu open jumps to the window's top edge keeps its place, submenu beside its row
Alerts list jumps to the window's top edge keeps its place in the chart
Star a timeframe (caret moves 74px), then scroll list still, then left behind on screen list still, then follows the page

Both forms were also reproduced on the live demo before the change: the timeframe list ended
208px under its button after a 200px scroll, and a time-axis right-click menu moved to 8px
from the top of the window.

The same scroll with the other floating surfaces open showed nothing to fix: the layout
picker, the chart settings dialog and the drawing-tool flyouts already move with the chart,
and the symbol search and indicators dialogs cover the window and keep the page from
scrolling.

Checklist

  • This PR does one thing (one fix, one feature, one refactor, or one docs change)
  • npm run typecheck, npm run lint, npm test, and npm run build all pass
  • Tests have been added / updated (for bug fixes / features)
  • Documentation in docs/ has been added / updated (for public interface or feature changes)
  • CHANGELOG.md has an entry under [Unreleased] (for user-visible changes)
  • I have signed the CLA (the bot asks in this PR)
  • I have reviewed this pull request myself (self-review)

Future work

  • A host that places a menu itself through the machine's api.reposition({ getAnchorRect })
    still hands the kit no anchor, so that menu is not covered. A kit method that opens a menu
    against a rectangle would close the gap.
  • A trigger inside its own scrolling container within the host: scrolling that container
    still leaves the list where it opened. No menu in Vela is built that way.

Note

Low Risk
UI positioning fix in the dropdown component with focused tests; no auth, data, or API surface changes beyond menu placement.

Overview
Open dropdown menus now stay attached to their host when the page scrolls, instead of staying fixed on the viewport while triggers move away.

In @luxalgo/vela-ui, menu anchors are stored as offsets inside the host (pin / anchorRect) rather than a one-time viewport rectangle. Trigger opens pin on open; openAt (context menus, alerts, etc.) pins the click point the same way and repositions through that anchor. Favorite/star shifts that move the caret inside the host still leave an already-open list where it opened, and the next open uses the new trigger position.

Changelogs for Vela and vela-ui document the fix. test/dropdown-menu-anchor.test.ts covers scroll, trigger shift, openAt, and reopen-from-selection behavior in jsdom.

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

A dropdown menu held its anchor in viewport coordinates, taken once as it
opened. On a page that scrolls around the chart, each re-placement put the
list back at that spot on screen while its trigger scrolled away, so the
timeframe, chart style and time zone menus came loose from their buttons.
A menu opened with openAt had no anchor for those re-placements at all and
fell back to the window's corner: a right-click menu or the alerts list
jumped to the top of the window on the first scroll.

The anchor is now held as an offset inside the host, for a trigger and for
a point alike. The list keeps its place in the host: a page that scrolls
the host carries it along, and a trigger that moves inside the host still
leaves it where it opened, which is what the pin was for (starring a
timeframe shifts the caret). A chart that fills its page sees no change.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Nov 17, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 14bebfc0-7271-49a9-9554-ff01881da3f8)

@alexgrover
alexgrover merged commit 0dfe2f4 into dev Nov 17, 2026
3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant