fix: crash on mobile caused by ChartTooltipContent outside ChartContainer#54
Merged
lukekarrys merged 1 commit intovltpkg:mainfrom Mar 5, 2026
Merged
Conversation
…iner The mobile chart code paths (introduced in vltpkg#52) use <ResponsiveContainer> instead of <ChartContainer>, but the tooltip inside them used <ChartTooltipContent> which calls useChart() — a hook that requires <ChartContainer>'s context. This throws immediately when Recharts renders the tooltip component, crashing the app on screens < 768px. Fix: Add a standalone MobileTooltipContent component that provides the same tooltip UI without depending on useChart()/ChartContext. The desktop code paths continue using ChartTooltipContent inside ChartContainer as before.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The benchmarks app crashes on mobile screens (< 768px) with the ErrorBoundary message:
The same crash occurs on desktop when resizing the browser window below 768px.
Root Cause
The mobile chart code paths (introduced in #52) use
<ResponsiveContainer>directly instead of<ChartContainer>. However, the tooltip inside them still used<ChartTooltipContent>, which callsuseChart()— a hook that requires<ChartContainer>'s React context.When Recharts renders the tooltip component (even when inactive),
useChart()throws:This is caught by the ErrorBoundary, showing the crash screen.
Why it only happens on mobile:
useMediaQuery('(max-width: 767px)')initializes asfalseuseEffectfires and flipsisMobiletotrueResponsiveContainerChartTooltipContentrenders → callsuseChart()→ throwsFix
Added a standalone
MobileTooltipContentcomponent that provides the same tooltip UI (color indicators, DNF support, formatted values) without depending onuseChart()/ChartContext. Replaced the two mobileChartTooltipusages with Recharts' native<Tooltip>+MobileTooltipContent.Desktop code paths continue using
ChartTooltipContentinsideChartContainerunchanged.Changes
app/src/components/variation/chart.tsxMobileTooltipContent, replace mobile tooltip usageBuild: ✅
tsc -b && vite buildcleanFormat: ✅ Prettier clean