Repository navigation
fix(perps): keep the chart time axis off the trade buttons - #47505
georgewrmarshall merged 2 commits into
Conversation
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/perps (2 files, +22 -14)
|
Builds ready [21f4430] [reused from 0eed673]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 3 warn · 🔴 3 fail)
Bundle Size Diffs
|
21f4430 to
b1c50ee
Compare
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Builds ready [b1c50ee]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 2 warn · 🔴 3 fail)
Bundle Size Diffs
|
Builds ready [1cf2526] [reused from b1c50ee]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 2 warn · 🔴 3 fail)
Bundle Size Diffs
|
1cf2526 to
b1c50ee
Compare
Builds ready [b1c50ee]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 2 warn · 🔴 3 fail)
Bundle Size Diffs
|
b1c50ee to
18a1d1b
Compare
The open time was captured when the mock module loaded, so it was older than the history bars and lightweight-charts crashed the market page. Co-authored-by: Cursor <cursoragent@cursor.com>
The time-axis canvas uses z-index 2, and the chart wrapper did not create a stacking context, so the canvas received clicks meant for the sticky trade buttons. Co-authored-by: Cursor <cursoragent@cursor.com>
acd25bb to
1414708
Compare
| style={{ | ||
| position: 'relative', | ||
| // Confines the chart canvas z-index so it cannot paint over the sticky footer. | ||
| isolation: 'isolate', |
There was a problem hiding this comment.
This is what made the Long, Short, and Close clicks fail in Chrome e2e once the page stopped crashing. Lightweight Charts draws the time axis on a canvas with position:absolute and z-index:2. The wrapper is only position:relative, which does not create a stacking context, so that canvas was compared with the sticky footer and received the click. isolation:isolate resolves the chart z-index inside the chart, and the footer then paints above it because it comes later in the tree. A higher z-index on the footer would also work, but it would have to stay above every chart layer.
https://www.joshwcomeau.com/css/stacking-contexts/#airtight-abstractions-with-isolation-6
| return { | ||
| channel: 'candle', | ||
| data: { | ||
| t: now, |
There was a problem hiding this comment.
This is what crashed the AVAX market page before the buttons could be clicked. The history mocks place their newest bar at request time minus 5 minutes, so an open time captured when this module loads is older than that bar. lightweight-charts then throws "Cannot update oldest data" and the error boundary replaces the page, which is the timeout on perps-long-cta-button in Chrome e2e. t is the subscription time, and T is one millisecond short of a 5 minute bar, matching the interval the chart requests.
Builds ready [1414708]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 4 warn · 🔴 3 fail)
Bundle Size Diffs
|
|
Pull request removed from stack



Description
Chrome e2e on the Grotzec Hero price change failed in
perps-position-lifecycle.spec.tsandperps-geo-block.spec.ts. Two separate bugs.What was going wrong
The CI screenshots were the error page, not a layout with a missing button. The chart threw
Cannot update oldest data, React Router replaced the market page, and the Long/Short wait then timed out. The AVAX live-candle mock set its open time when the file loaded (Date.now() - 5m). History bars are built when the request arrives, so that live candle was older than the last bar andseries.update()threw.After the candle time was corrected, the page stayed up. The screenshot showed Close long still there, and the test was waiting for Long to come back. Logging the intercepted click named the element on top: a 680×28 canvas,
position: absolute; z-index: 2, which is the lightweight-charts time axis.AmountDisplayLgmakes the price row tall enough that this canvas overlaps the sticky footer in CI's window. The footer has no z-index, andposition: relativedoes not create a stacking context, so the canvas received the click. The click retry scrolled the button away from the footer, the close update was missed, and Long never returned.The fix
isolation: isolateon the chart wrapper keeps that z-index inside the chart. The footer comes later in the tree and paints above it, so the trade buttons receive the click.The candle mock builds
tandTwhen the test subscribes, withtset to that moment, so the live candle is newer than the history. Chrome e2e passed after both changes.Changelog
CHANGELOG entry: Fixed the perpetuals chart time axis covering the trade buttons.
Related issues
Fixes the Chrome e2e failures on #47503.
Manual testing steps
Screenshots/Recordings
The chart drawing is unchanged. Where the chart meets the sticky footer, the time axis no longer receives the click.
Before
The time axis received clicks meant for Long, Short, and Close.
After
Those buttons receive the clicks.
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Small CSS stacking-context change on the chart container and e2e mock timing only; no production trading or auth logic changes.
Overview
Fixes Perps market detail where the lightweight-charts time-axis canvas could sit above the sticky Long / Short / Close footer and steal clicks when the chart overlaps that area in smaller viewports. The chart wrapper now uses
isolation: isolateso internal canvas stacking stays below the footer.Also fixes Chrome e2e failures on AVAX flows: the Hyperliquid candle subscribe mock no longer uses candle open/close times frozen at module load. It switches to
dynamicFollowUpsot/Tare set at subscribe time, keeping the live candle newer thancandleSnapshothistory and avoidingseries.update()“Cannot update oldest data” crashes that disabled close-position flows.Reviewed by Cursor Bugbot for commit 1414708. Bugbot is set up for automated code reviews on this repo. Configure here.