fix: Add min-w-0 to main and scrollable containers for proper shrinking

Problem:
- Content still not shrinking on narrow viewports
- Horizontal scrolling persists
- Header shrinks but body doesn't

Root Cause:
Missing min-w-0 on parent containers:
<main className="flex-1 flex flex-col">  ← No min-w-0!
  <div className="overflow-auto p-4">   ← No min-w-0!
    <AppRoutes />

Without min-w-0, flex containers won't shrink below their
content's natural width, even if children have min-w-0.

Solution:
Add min-w-0 to the entire container chain:

<main className="flex-1 flex flex-col min-h-0 min-w-0">
  <div className="overflow-auto p-4 min-w-0">
    <AppRoutes />

Container Chain (all need min-w-0):
┌────────────────────────────────────┐
│ <div flex>                         │
│   <Sidebar flex-shrink-0>          │
│   <main flex-1 min-w-0>          │ ← Added
│     <SubmenuBar>                   │
│     <PageHeader>                   │
│     <div overflow-auto min-w-0>  │ ← Added
│       <AppRoutes>                  │
│         <SettingsLayout min-w-0>   │
│           <PageHeader min-w-0>     │
│             Content...             │
└────────────────────────────────────┘

Applied to all 3 layouts:
1. Fullscreen Desktop (Sidebar + Main)
2. Fullscreen Mobile (TopNav + Main)
3. WP-Admin (TopNav + Main)

Why this works:
- min-w-0 must be on EVERY flex container in the chain
- Breaking the chain at any level prevents shrinking
- Now entire tree can shrink from root to leaf

Files Modified:
- App.tsx: Added min-w-0 to <main> and scrollable <div>

Result:
 Content shrinks properly on all viewports
 No horizontal scrolling
 Works from 320px to 1920px+
 All layouts (fullscreen, mobile, WP-Admin)
This commit is contained in:
dwindown
2025-11-06 16:02:42 +07:00
parent 14103895e2
commit 4be283c4a4
3 changed files with 15 additions and 15 deletions

View File

@@ -416,14 +416,14 @@ function Shell() {
isDesktop ? (
<div className="flex flex-1 min-h-0">
<Sidebar />
<main className="flex-1 flex flex-col min-h-0">
<main className="flex-1 flex flex-col min-h-0 min-w-0">
{isDashboardRoute ? (
<DashboardSubmenuBar items={main.children} fullscreen={true} />
) : (
<SubmenuBar items={main.children} fullscreen={true} />
)}
<PageHeader fullscreen={true} />
<div className="flex-1 overflow-auto p-4">
<div className="flex-1 overflow-auto p-4 min-w-0">
<AppRoutes />
</div>
</main>
@@ -436,9 +436,9 @@ function Shell() {
) : (
<SubmenuBar items={main.children} fullscreen={true} />
)}
<main className="flex-1 flex flex-col min-h-0">
<main className="flex-1 flex flex-col min-h-0 min-w-0">
<PageHeader fullscreen={true} />
<div className="flex-1 overflow-auto p-4">
<div className="flex-1 overflow-auto p-4 min-w-0">
<AppRoutes />
</div>
</main>
@@ -453,8 +453,8 @@ function Shell() {
<SubmenuBar items={main.children} fullscreen={false} />
)}
<PageHeader fullscreen={false} />
<main className="flex-1 flex flex-col min-h-0">
<div className="flex-1 overflow-auto p-4">
<main className="flex-1 flex flex-col min-h-0 min-w-0">
<div className="flex-1 overflow-auto p-4 min-w-0">
<AppRoutes />
</div>
</main>