Skip to content

fix(chart): z-index drawing canvas above lightweight-charts' own canvases#2145

Merged
dcccrypto merged 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/drawing-canvas-z-index
May 7, 2026
Merged

fix(chart): z-index drawing canvas above lightweight-charts' own canvases#2145
dcccrypto merged 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/drawing-canvas-z-index

Conversation

@0x-SquidSol
Copy link
Copy Markdown
Contributor

Summary

Drawings on the price chart were saving to state and localStorage correctly (the toolbar's clear-all confirmation reflected the count) but never became visible on screen. Root cause: the overlay canvas was relying on DOM order alone to stack above lightweight-charts' own canvases — both at `z-index: auto` (= 0). By spec the drawing canvas (later DOM sibling) should paint on top, and that worked in local dev / Vitest, but in production the chart container's internal stacking context wins the tie-break and lightweight-charts' canvases paint above the drawing canvas instead.

Fix

One-line change: add explicit `z-[1]` to the drawing canvas.

  • Drawing canvas at `z-index: 1` — above the chart's canvases (z-auto)
  • Below the existing z-10 UI badges (empty-state, hover-tooltip, position-summary, drawing toolbar) — preserves the existing visual layering contract
  • `pointer-events: none` unchanged — chart pan/zoom still works through this layer
  • Comment in source explains the tie-break failure mode for future readers

Test plan

  • 64/64 ChartDrawingOverlay tests passing — the existing assertion uses `className.toContain('pointer-events-none')` which still matches
  • Manual smoke: open a market → toolbar at top-left → click horizontal-line tool → click on a candle → purple line appears at that price level
  • Manual smoke: drag a rectangle in the candle area → purple shaded box renders + persists across reload
  • Manual smoke: pan the chart → drawings move with the price/time grid

🤖 Generated with Claude Code

…canvases

Drawings were saving to state and localStorage correctly, the
toolbar's clear-all confirmation reflected the drawing count, but
the drawings never became visible on the chart. The overlay was
relying on DOM order alone to stack above lightweight-charts'
canvases (the canvas was rendered after the chart container, both
at z-index auto, so by spec the drawing canvas should paint on
top). That worked in local dev but broke in production — most
likely the chart container's internal stacking context (it's
positioned via lightweight-charts' table layout) wins the
stacking-order tie-break with z-auto siblings under some
combinations of contain:paint and the inset-0 absolute positioning,
and the chart canvases paint above the drawing canvas instead.

Fix: explicit z-[1] on the drawing canvas. Sits above the chart's
own canvases (which paint at z-auto) and below the z-10 UI badges
(empty-state overlay, hover-tooltip, position-summary, drawing
toolbar). pointer-events stays disabled so chart pan/zoom keeps
working through this layer.

Tests: 64/64 ChartDrawingOverlay tests passing.
@0x-SquidSol 0x-SquidSol requested a review from dcccrypto as a code owner May 6, 2026 16:30
@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

@0x-SquidSol is attempting to deploy a commit to the Khubair Nasir's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@0x-SquidSol has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 33 minutes and 23 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2e8634cd-4905-46f4-84d3-e57f283c7ce0

📥 Commits

Reviewing files that changed from the base of the PR and between 59c3f78 and f5e92b6.

📒 Files selected for processing (1)
  • app/components/trade/ChartDrawingOverlay.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dcccrypto dcccrypto merged commit e651e93 into dcccrypto:main May 7, 2026
9 of 12 checks passed
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.

2 participants