Fix mobile dashboard layout: separate metric grid from full-width widgets - #569
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…roper padding Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes critical mobile dashboard layout issues by replacing the broken horizontal scroll carousel with a responsive 2-column grid for metric cards and full-width stacking for charts/tables. The changes improve mobile UX by eliminating card overflow and making all content properly visible on small screens.
Changes:
- Updated DashboardRenderer mobile threshold from 640px to 768px and split widget rendering by type
- Removed double padding in DashboardView on mobile by changing p-4 to p-0
- Hid theme toggle and language switcher on mobile in AppHeader to reduce clutter
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/plugin-dashboard/src/DashboardRenderer.tsx | Changed mobile threshold to 768px, split metric widgets (2-col grid) from other widgets (full-width stack), removed horizontal scroll, added px-4 container padding |
| packages/plugin-dashboard/src/tests/DashboardRenderer.mobile.test.tsx | Added comprehensive test coverage for mobile layout with 5 test cases covering threshold detection and widget separation |
| apps/console/src/components/DashboardView.tsx | Changed mobile padding from p-4 to p-0 to avoid double padding with DashboardRenderer's internal px-4 |
| apps/console/src/components/AppHeader.tsx | Added hidden sm:flex to theme toggle and language switcher to reduce mobile header clutter |
| {metricWidgets.map((widget: DashboardWidgetSchema, index: number) => renderWidget(widget, index))} | ||
| </div> | ||
| )} | ||
|
|
||
| {/* Other widgets (charts, tables): full-width vertical stack */} | ||
| {otherWidgets.length > 0 && ( | ||
| <div className="flex flex-col gap-4"> | ||
| {otherWidgets.map((widget: DashboardWidgetSchema, index: number) => renderWidget(widget, index, true))} |
There was a problem hiding this comment.
Potential React key collision in mobile layout. When widgets are split into metricWidgets and otherWidgets arrays and then mapped separately, the index parameter passed to renderWidget is the index within each filtered array (0, 1, 2...), not the original index from schema.widgets. If widgets lack explicit id or title fields, this creates duplicate keys like widget-0, widget-1 appearing in both metric and non-metric sections. To fix this, either pass the original widget index from schema.widgets, or prefix the fallback key with the widget type (e.g., metric-widget-0 vs other-widget-0).
|
|
||
| <div className="flex-1 overflow-hidden flex flex-col sm:flex-row relative"> | ||
| <div className="flex-1 overflow-auto p-4 sm:p-6"> | ||
| <div className="flex-1 overflow-auto p-0 sm:p-6"> |
There was a problem hiding this comment.
Padding inconsistency between 640px and 768px. DashboardView applies sm:p-6 (24px padding) at 640px+, while DashboardRenderer applies px-4 (16px padding) in mobile mode which extends up to 767px. This creates double horizontal padding (40px total) in the 640-767px range. The DashboardView should use md:p-6 instead of sm:p-6 to align with DashboardRenderer's 768px mobile threshold, or both should consistently use the same breakpoint.
| <div className="flex-1 overflow-auto p-0 sm:p-6"> | |
| <div className="flex-1 overflow-auto p-0 md:p-6"> |
Mobile dashboard rendered all widgets in a horizontal scroll carousel with fixed
w-[85vw]width, causing stat cards to overflow and charts to be unreadable. Header was cluttered with theme/language controls.Changes
DashboardRenderer.tsx
640px→768pxgrid grid-cols-2 gap-3flex flex-col gap-4(full-width)px-4container paddingw-[85vw]fixed width and horizontal scroll snapDashboardView.tsx
p-4→p-0(DashboardRenderer handles its own padding)AppHeader.tsx
hidden sm:flexImplementation
Desktop layout (≥768px) unchanged.
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.