Repository navigation
fix(ui): an open menu keeps its place in its host when the page scrolls - #409
Merged
Merged
Conversation
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>
Bugbot couldn't run - usage limit reachedBugbot 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) |
5 of 7 tasks
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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:
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.
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
npm run typecheck,npm run lint,npm test, andnpm run buildall passdocs/has been added / updated (for public interface or feature changes)CHANGELOG.mdhas an entry under[Unreleased](for user-visible changes)Future work
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.
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-uidocument the fix.test/dropdown-menu-anchor.test.tscovers 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.