Skip to content

This PR fixes responsive layout issues with benchmark charts on narrow mobile screens. #221#228

Merged
sapnilbiswas merged 2 commits into
Stanzin7:masterfrom
tejaswiverma121-byte:graph
Apr 23, 2026
Merged

This PR fixes responsive layout issues with benchmark charts on narrow mobile screens. #221#228
sapnilbiswas merged 2 commits into
Stanzin7:masterfrom
tejaswiverma121-byte:graph

Conversation

@tejaswiverma121-byte
Copy link
Copy Markdown
Contributor

@tejaswiverma121-byte tejaswiverma121-byte commented Apr 23, 2026

Changes Made

  • Reduced default chart height in ->TrendChart.jsx
  • Rotated X-axis labels for better readability on small screens
  • Added extra bottom spacing for axis labels
  • Preserved chart responsiveness within card boundaries

Issue Fixed
On very narrow viewports (~300px width), benchmark charts were overflowing their cards and overlapping adjacent content, making the layout cluttered and hard to read.

Testing
Tested on:

  • Viewport: 300px × 611px

Verified that:

  • Charts stay within their containers
  • X-axis labels no longer overlap other elements and it should not overlap on the graph x axis
  • Layout remains clean and readable on mobile devices

Demo

I am attaching video reference

WhatsApp.Video.2026-04-23.at.17.22.31.mp4

Closes #221

Summary by CodeRabbit

  • Bug Fixes
    • Improved chart display with better label positioning and visibility on the Benchmarks page
    • Fixed grid layout constraints to prevent content overflow and improve responsiveness across different screen sizes

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

The changes address responsive rendering issues on narrow mobile viewports by constraining flex layouts with minWidth: 0 in the React component, improving X-axis label readability through rotation and positioning, and updating CSS Grid column sizing with minmax(0, 1fr) to allow content to shrink without overflow.

Changes

Cohort / File(s) Summary
TrendChart Component Layout
frontend/src/components/benchmarks/TrendChart.jsx
Chart container restructured with flex column layout and minWidth: 0 constraint; title configured with flexShrink: 0; ResponsiveContainer updated with minWidth={0}; X-axis enhanced with end label preservation, adjusted tick density, rotated/positioned labels, disabled tick lines, and explicit tick label height.
BenchmarksPage Grid Styling
frontend/src/pages/research/BenchmarksPage.scss
Grid columns updated to use minmax(0, 1fr) instead of plain 1fr (applied at both base and max-width: 968px breakpoint); .chart-card assigned min-width: 0 to prevent overflow of contained elements; comment removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A flex and a grid, with minWidth: 0,
Charts now shrink gracefully, no overflow show!
On tiny mobile screens they dance and align,
Rotated labels gleam in responsive design.
The benchmark bugs hop away, crisis averted—
One fluffy reviewer, thoroughly converted! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main fix: responsive layout issues with benchmark charts on narrow mobile screens, directly matching the changeset.
Linked Issues check ✅ Passed The code changes address all primary objectives from issue #221: constrained chart resizing with flex/minWidth, improved X-axis label readability through rotation and positioning, and grid sizing adjustments to prevent overflow.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing benchmark chart responsive layout issues; no unrelated modifications to other features or unrelated code areas were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@github-actions github-actions Bot added bug Bug report or bug fix related work area: frontend Changes to the React frontend area: infra CI, deployment, database, or repository automation changes and removed bug Bug report or bug fix related work labels Apr 23, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/components/benchmarks/TrendChart.jsx`:
- Around line 39-49: The ResponsiveContainer inside the TrendChart component can
overflow because the parent is a flex column and the title uses flexShrink: 0;
wrap the ResponsiveContainer in a new div (e.g., a flex child wrapper) with
style {flex: 1, minHeight: 0} so the wrapper consumes the remaining space and
allows ResponsiveContainer (width="100%" height="100%") to size correctly;
locate the JSX around ResponsiveContainer in TrendChart.jsx and insert the
wrapper div directly around the ResponsiveContainer element to fix the layout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bfb2c24f-03e3-4d3b-b467-b7384a7da1ff

📥 Commits

Reviewing files that changed from the base of the PR and between 8cc1ddd and 921acf4.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • frontend/src/components/benchmarks/TrendChart.jsx
  • frontend/src/pages/research/BenchmarksPage.scss

Comment on lines +39 to 49
<div className="trend-chart" style={{ width: '100%', height, display: 'flex', flexDirection: 'column', minWidth: 0 }}>
<h4 className="trend-chart__title" style={{
fontSize: '0.9375rem',
fontWeight: 600,
marginBottom: '1rem'
marginBottom: '1rem',
flexShrink: 0
}}>
{title}
</h4>
<ResponsiveContainer width="100%" height="100%">
<ResponsiveContainer width="100%" height="100%" minWidth={0}>
<LineChart data={formattedData} margin={{ top: 5, right: 30, left: 20, bottom: 5 }}>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, locate the file and check its size
find . -name "TrendChart.jsx" -type f

Repository: Stanzin7/ExtensionShield

Length of output: 119


🏁 Script executed:

# Once found, read the file to see the actual code
cat -n frontend/src/components/benchmarks/TrendChart.jsx

Repository: Stanzin7/ExtensionShield

Length of output: 3639


🏁 Script executed:

# Check for CSS files that might style .trend-chart
find ./frontend -name "*.css" -o -name "*.scss" | xargs grep -l "trend-chart" 2>/dev/null | head -5

Repository: Stanzin7/ExtensionShield

Length of output: 117


🏁 Script executed:

# Also check if TrendChart is used with height constraints
grep -r "TrendChart" ./frontend --include="*.jsx" --include="*.js" -B 2 -A 2 | head -30

Repository: Stanzin7/ExtensionShield

Length of output: 2243


🏁 Script executed:

# Check the SCSS for chart layout constraints
cat ./frontend/src/pages/research/BenchmarksPage.scss

Repository: Stanzin7/ExtensionShield

Length of output: 20830


🏁 Script executed:

# Check BenchmarksPage.jsx for actual TrendChart usage with height parameter
cat ./frontend/src/pages/research/BenchmarksPage.jsx | head -150

Repository: Stanzin7/ExtensionShield

Length of output: 5675


Wrap ResponsiveContainer in a flex child to prevent chart overflow under fixed-height container.

When TrendChart uses its default height={350}, the flex column allocates the full 350px to ResponsiveContainer via height="100%" while the title (with flexShrink: 0) also consumes space. This causes the chart to overflow its container. Add a wrapper with flex: 1 and minHeight: 0 around ResponsiveContainer to distribute remaining height after the title.

Suggested fix
      <h4 className="trend-chart__title" style={{ 
        fontSize: '0.9375rem', 
        fontWeight: 600, 
        marginBottom: '1rem',
        flexShrink: 0
      }}>
        {title}
      </h4>
+     <div style={{ flex: 1, minHeight: 0, minWidth: 0 }}>
       <ResponsiveContainer width="100%" height="100%" minWidth={0}>
         <LineChart data={formattedData} margin={{ top: 5, right: 30, left: 20, bottom: 5 }}>
           <CartesianGrid strokeDasharray="3 3" stroke="var(--theme-border-subtle)" />
           <XAxis 
             dataKey="date" 
             stroke="var(--theme-text-subtle)"
             style={{ fontSize: '0.75rem' }}
             interval="preserveEnd"
             minTickGap={20}
             angle={-35}
             textAnchor="end"
             dx={-5}
             dy={10}
             height={60}
             tickLine={false}
           />
           <YAxis 
             stroke="var(--theme-text-subtle)"
             style={{ fontSize: '0.75rem' }}
           />
           <Tooltip content={<CustomTooltip />} />
           <Line 
             type="monotone" 
             dataKey="value" 
             stroke={color} 
             strokeWidth={2}
             dot={{ fill: color, r: 4 }}
             activeDot={{ r: 6 }}
             isAnimationActive={true}
             animationDuration={1200}
             animationEasing="ease-out"
           />
         </LineChart>
       </ResponsiveContainer>
+     </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div className="trend-chart" style={{ width: '100%', height, display: 'flex', flexDirection: 'column', minWidth: 0 }}>
<h4 className="trend-chart__title" style={{
fontSize: '0.9375rem',
fontWeight: 600,
marginBottom: '1rem'
marginBottom: '1rem',
flexShrink: 0
}}>
{title}
</h4>
<ResponsiveContainer width="100%" height="100%">
<ResponsiveContainer width="100%" height="100%" minWidth={0}>
<LineChart data={formattedData} margin={{ top: 5, right: 30, left: 20, bottom: 5 }}>
<div className="trend-chart" style={{ width: '100%', height, display: 'flex', flexDirection: 'column', minWidth: 0 }}>
<h4 className="trend-chart__title" style={{
fontSize: '0.9375rem',
fontWeight: 600,
marginBottom: '1rem',
flexShrink: 0
}}>
{title}
</h4>
<div style={{ flex: 1, minHeight: 0, minWidth: 0 }}>
<ResponsiveContainer width="100%" height="100%" minWidth={0}>
<LineChart data={formattedData} margin={{ top: 5, right: 30, left: 20, bottom: 5 }}>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/components/benchmarks/TrendChart.jsx` around lines 39 - 49, The
ResponsiveContainer inside the TrendChart component can overflow because the
parent is a flex column and the title uses flexShrink: 0; wrap the
ResponsiveContainer in a new div (e.g., a flex child wrapper) with style {flex:
1, minHeight: 0} so the wrapper consumes the remaining space and allows
ResponsiveContainer (width="100%" height="100%") to size correctly; locate the
JSX around ResponsiveContainer in TrendChart.jsx and insert the wrapper div
directly around the ResponsiveContainer element to fix the layout.

@sapnilbiswas
Copy link
Copy Markdown
Collaborator

Hey @tejaswiverma121-byte, it works really well. I really appreciate your fix, however, I feel that this fix might create some issue around 350px. Please go through the code rabbit once and try fixing it. Also, there is one more concern about changes in package-lock.json any particular reason for the change?
Try fixing that

@github-actions github-actions Bot removed the area: infra CI, deployment, database, or repository automation changes label Apr 23, 2026
@tejaswiverma121-byte
Copy link
Copy Markdown
Contributor Author

tejaswiverma121-byte commented Apr 23, 2026

@sapnilbiswas
Screenshot 2026-04-23 at 6 18 20 PM
Sorry for that I was just surfing at the file it changed by mistake I had corrected it again.
And on 350px the resposiveness is working properly by the way none of the mobile use that much responsiveness I have checked at all the devices

Copy link
Copy Markdown
Collaborator

@sapnilbiswas sapnilbiswas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @tejaswiverma121-byte for working on this. Looks good to me
Will be merging soon

@sapnilbiswas sapnilbiswas merged commit 1b1b9da into Stanzin7:master Apr 23, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: frontend Changes to the React frontend bug Bug report or bug fix related work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Benchmark charts overflow and overlap on narrow mobile viewports

2 participants