Refactor Git Management Dialog with proper flex-based scrolling architecture

Completely refactored the Git Management Dialog to use a robust flex layout
that prevents overflow and enables proper scrolling regardless of content size.

Architecture Changes:
- Changed from max-h-[90vh] to h-[90vh] for consistent height
- Implemented proper flex container hierarchy with min-h-0 to prevent overflow
- Fixed header and tab list are non-scrollable (shrink-0)
- Tab content areas take remaining space and scroll independently
- Used data-[state=active]:flex to properly show/hide tabs in flex layout

Layout Structure:
DialogContent (h-[90vh], flex flex-col)
  ├── DialogHeader (shrink-0, border-b) ← Fixed
  └── Tabs Container (flex-1, min-h-0)
      ├── TabsList (shrink-0, border-b) ← Fixed
      └── TabsContent (flex-1, scrollable) ← Scrolls

Key Techniques:
- min-h-0: Allows flex children to shrink below content size
- flex-1: Takes all available space
- shrink-0: Prevents elements from shrinking
- ScrollArea wrapping for Branches and Compare tabs
- Direct height inheritance for DiffViewer (has internal layout)

This architecture is future-proof and will handle any additional content
or fields added to any tab without overflow issues.
This commit is contained in:
shakespeare.diy committed 2025-10-14 15:26:06 -05:00
1 parent 9c24785b11
commit d779dd102b
1 file changed
+62 -48
+62 -48
View File
@@ -7,6 +7,7 @@ import {
DialogTrigger, DialogTrigger,
} from '@/components/ui/dialog'; } from '@/components/ui/dialog';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { ScrollArea } from '@/components/ui/scroll-area';
import { import {
GitBranch, GitBranch,
GitCompare, GitCompare,
@@ -45,63 +46,76 @@ export function GitManagementDialog({
<> <>
<Dialog open={open} onOpenChange={onOpenChange}> <Dialog open={open} onOpenChange={onOpenChange}>
{children && <DialogTrigger asChild>{children}</DialogTrigger>} {children && <DialogTrigger asChild>{children}</DialogTrigger>}
<DialogContent className="max-w-6xl max-h-[90vh] p-0 flex flex-col"> <DialogContent className="max-w-6xl h-[90vh] p-0 flex flex-col gap-0">
<DialogHeader className="px-6 pt-6 pb-4 shrink-0"> {/* Fixed Header */}
<DialogHeader className="px-6 pt-6 pb-4 border-b shrink-0">
<DialogTitle className="flex items-center gap-2"> <DialogTitle className="flex items-center gap-2">
<GitBranch className="h-5 w-5" /> <GitBranch className="h-5 w-5" />
Git Management Git Management
</DialogTitle> </DialogTitle>
</DialogHeader> </DialogHeader>
<Tabs value={activeTab} onValueChange={setActiveTab} className="flex-1 flex flex-col overflow-hidden"> {/* Tabs Container - takes remaining space */}
<div className="border-b px-6 shrink-0"> <div className="flex-1 flex flex-col min-h-0">
<TabsList className="h-auto p-0 bg-transparent"> <Tabs value={activeTab} onValueChange={setActiveTab} className="flex-1 flex flex-col">
<TabsTrigger {/* Fixed Tab List */}
value="branches" <div className="border-b px-6 shrink-0">
className="gap-2 data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none" <TabsList className="h-auto p-0 bg-transparent">
> <TabsTrigger
<GitBranch className="h-4 w-4" /> value="branches"
Branches className="gap-2 data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none"
</TabsTrigger> >
<TabsTrigger <GitBranch className="h-4 w-4" />
value="changes" Branches
className="gap-2 data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none" </TabsTrigger>
> <TabsTrigger
<Settings className="h-4 w-4" /> value="changes"
Changes className="gap-2 data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none"
</TabsTrigger> >
<TabsTrigger <Settings className="h-4 w-4" />
value="compare" Changes
className="gap-2 data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none" </TabsTrigger>
> <TabsTrigger
<GitCompare className="h-4 w-4" /> value="compare"
Compare className="gap-2 data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none"
</TabsTrigger> >
</TabsList> <GitCompare className="h-4 w-4" />
</div> Compare
</TabsTrigger>
</TabsList>
</div>
{/* Branches Tab */} {/* Scrollable Tab Content */}
<TabsContent value="branches" className="mt-0 p-6 overflow-y-auto flex-1"> <TabsContent value="branches" className="flex-1 m-0 data-[state=active]:flex data-[state=active]:flex-col">
<BranchManager <ScrollArea className="flex-1">
projectId={projectId} <div className="p-6">
currentBranch={gitStatus?.currentBranch || null} <BranchManager
onBranchChange={handleBranchChange} projectId={projectId}
/> currentBranch={gitStatus?.currentBranch || null}
</TabsContent> onBranchChange={handleBranchChange}
/>
</div>
</ScrollArea>
</TabsContent>
{/* Changes Tab */} <TabsContent value="changes" className="flex-1 m-0 data-[state=active]:flex data-[state=active]:flex-col min-h-0">
<TabsContent value="changes" className="mt-0 overflow-y-auto flex-1"> <div className="flex-1 min-h-0">
<DiffViewer <DiffViewer
projectId={projectId} projectId={projectId}
compareFrom="HEAD" compareFrom="HEAD"
/> />
</TabsContent> </div>
</TabsContent>
{/* Compare Tab */} <TabsContent value="compare" className="flex-1 m-0 data-[state=active]:flex data-[state=active]:flex-col">
<TabsContent value="compare" className="mt-0 p-6 overflow-y-auto flex-1"> <ScrollArea className="flex-1">
<CompareView projectId={projectId} /> <div className="p-6">
</TabsContent> <CompareView projectId={projectId} />
</Tabs> </div>
</ScrollArea>
</TabsContent>
</Tabs>
</div>
</DialogContent> </DialogContent>
</Dialog> </Dialog>
</> </>