@@ -75,6 +75,11 @@ interface DocumentViewProps {
7575
7676// ── main component ────────────────────────────────────────────────────────────
7777
78+ // Explicit default so header/body columns share one width. Virtual rows are
79+ // position:absolute (detached from the table's column model), so `auto` widths
80+ // let thead and tbody size independently and drift out of alignment.
81+ const DEFAULT_COL_WIDTH = 200 ;
82+
7883export function DocumentView ( {
7984 connectionName,
8085 dbName,
@@ -664,7 +669,7 @@ export function DocumentView({
664669 /* Table view */
665670 < div ref = { tableContainerRef } className = "h-full w-full overflow-auto" >
666671 < table
667- className = "min-w-full w-max text-sm text-left relative"
672+ className = "min-w-full w-max text-sm text-left relative table-fixed "
668673 aria-label = { `${ collectionName } documents` }
669674 >
670675 < thead className = "text-xs text-muted-foreground uppercase bg-muted" >
@@ -678,14 +683,14 @@ export function DocumentView({
678683 />
679684 </ th >
680685 ) }
681- < th className = "px-4 py-3 w-[50px] whitespace-nowrap font-medium text-center sticky left-0 top-0 z-30 bg-muted" > #</ th >
686+ < th className = { cn ( "px-4 py-3 w-[50px] whitespace-nowrap font-medium text-center sticky top-0 z-30 bg-muted" , showSelectMode ? "left-[44px]" : "left-0" ) } > #</ th >
682687 { allFields . map ( ( key ) => (
683688 < th
684689 key = { key }
685690 className = "px-4 py-3 whitespace-nowrap font-medium sticky top-0 z-20 bg-muted pr-6 group/th hover:bg-muted/80 transition-colors border-r"
686691 style = { {
687- width : columnWidths [ key ] ? `${ columnWidths [ key ] } px` : 'auto' ,
688- maxWidth : columnWidths [ key ] ? `${ columnWidths [ key ] } px` : '300px' ,
692+ width : `${ columnWidths [ key ] ?? DEFAULT_COL_WIDTH } px` ,
693+ maxWidth : `${ columnWidths [ key ] ?? DEFAULT_COL_WIDTH } px` ,
689694 } }
690695 >
691696 < div className = "flex items-center gap-1 cursor-pointer truncate" onClick = { ( ) => handleSort ( key ) } >
@@ -736,16 +741,16 @@ export function DocumentView({
736741 />
737742 </ td >
738743 ) }
739- < td className = { cn ( "px-4 py-3 font-mono text-xs text-center text-muted-foreground sticky left-0 z-10 bg-background group-hover:bg-muted/50 transition-colors" , isSelected && "bg-primary/5 group-hover:bg-primary/10" ) } >
744+ < td className = { cn ( "px-4 py-3 w-[50px] font-mono text-xs text-center text-muted-foreground sticky z-10 bg-background group-hover:bg-muted/50 transition-colors" , showSelectMode ? "left-[44px]" : "left-0 ", isSelected && "bg-primary/5 group-hover:bg-primary/10" ) } >
740745 { index + 1 + ( page - 1 ) * limit }
741746 </ td >
742747 { allFields . map ( ( key ) => (
743748 < td
744749 key = { key }
745750 className = "px-4 py-3 align-top truncate border-r relative overflow-hidden"
746751 style = { {
747- maxWidth : columnWidths [ key ] ? `${ columnWidths [ key ] } px` : '300px' ,
748- width : columnWidths [ key ] ? `${ columnWidths [ key ] } px` : 'auto'
752+ maxWidth : `${ columnWidths [ key ] ?? DEFAULT_COL_WIDTH } px` ,
753+ width : `${ columnWidths [ key ] ?? DEFAULT_COL_WIDTH } px`
749754 } }
750755 >
751756 < CellValue value = { doc [ key ] } onViewClick = { handleViewValue } />
0 commit comments