fix: clip highlight lines to table bounds, fix insert button centering, footer buttons

- Blue highlight lines for both column and row inserts are now clipped
  to the table boundaries via a relative overflow-hidden wrapper div
  around the table, so they no longer extend beyond the table edges.

- Insert-column + button is now absolutely positioned with
  left-1/2 top-1/2 -translate-x/y-1/2 for pixel-perfect centering
  on the column border (previously used flex centering which was
  slightly off due to Tooltip wrapper).

- Added ml-1 margin before the column delete button so it doesn't
  overlap with the insert-column + button hover zone.

- Added a second '+ Add row' button just below the table (above the
  footer), in addition to the one in the footer bar.

- Added '+ Add column' button in the footer bar, right next to the
  '+ Add row' button.

Co-authored-by: milvasic <milvasic@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-02-07 00:05:41 +00:00
parent ac403c6047
commit 6c6e1462bc
1 changed files with 156 additions and 141 deletions

View File

@ -199,6 +199,8 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
<div className="flex flex-col h-full">
{/* Scrollable table area */}
<div className="flex-1 overflow-auto px-4 pb-2">
{/* Clip wrapper: ensures blue highlight lines don't extend beyond the table */}
<div className="relative overflow-hidden">
<table className="w-full border-collapse text-sm">
{/* ============ STICKY HEADER ============ */}
<thead className="sticky top-0 z-20">
@ -217,7 +219,7 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
{/* ---- Insert-column zone (between col-1 and col) ---- */}
{col > 0 && (
<div
className="group/cins absolute -left-4 top-0 bottom-0 w-8 z-30 flex items-center justify-center cursor-pointer"
className="group/cins absolute -left-4 top-0 bottom-0 w-8 z-30 cursor-pointer"
onClick={() => insertColumnAt(col)}
>
{/* Blue vertical line through the entire table */}
@ -225,12 +227,12 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
className="absolute left-1/2 -translate-x-1/2 top-0 w-0 group-hover/cins:w-[3px] bg-blue-500/70 transition-all pointer-events-none"
style={{ bottom: "-200rem" }}
/>
{/* + button */}
{/* + button — absolutely centered on the column border */}
<Tooltip>
<TooltipTrigger asChild>
<button
type="button"
className="relative z-10 flex items-center justify-center size-5 rounded-full bg-background border border-border text-muted-foreground cursor-pointer opacity-0 group-hover/cins:opacity-100 hover:text-primary hover:border-primary transition-all shadow-sm"
className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-10 flex items-center justify-center size-5 rounded-full bg-background border border-border text-muted-foreground cursor-pointer opacity-0 group-hover/cins:opacity-100 hover:text-primary hover:border-primary transition-all shadow-sm"
>
<PlusIcon className="size-3" />
</button>
@ -241,7 +243,7 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
)}
{/* Header cell — bg covers input + sort + delete */}
<div className="flex items-center gap-0.5 bg-accent/50 border border-border">
<div className="flex items-center bg-accent/50 border border-border">
<input
ref={(el) => setInputRef(`-1:${col}`, el)}
style={{ fontFamily: MONO_FONT }}
@ -268,7 +270,7 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
<TooltipTrigger asChild>
<button
type="button"
className="flex items-center justify-center size-7 rounded cursor-pointer opacity-40 hover:opacity-100 hover:bg-destructive/10 hover:text-destructive transition-all"
className="flex items-center justify-center size-7 ml-1 rounded cursor-pointer opacity-40 hover:opacity-100 hover:bg-destructive/10 hover:text-destructive transition-all"
onClick={() => removeColumn(col)}
>
<TrashIcon className="size-3" />
@ -308,10 +310,10 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
<td className="w-7 min-w-7 text-center align-middle relative">
{rowIdx > 0 && (
<div
className="group/rins absolute -top-[10px] -left-1 right-0 h-5 z-10 flex items-center justify-end cursor-pointer"
className="group/rins absolute -top-[10px] -left-1 right-0 h-5 z-10 cursor-pointer"
onClick={() => insertRowAt(rowIdx)}
>
{/* Blue horizontal line extending across the full table */}
{/* Blue horizontal line extending across the table */}
<div
className="absolute top-1/2 -translate-y-1/2 left-0 h-0 group-hover/rins:h-[3px] bg-blue-500/70 transition-all pointer-events-none"
style={{ width: "200rem" }}
@ -321,7 +323,7 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
<TooltipTrigger asChild>
<button
type="button"
className="relative z-10 flex items-center justify-center size-5 rounded-full bg-background border border-border text-muted-foreground cursor-pointer opacity-0 group-hover/rins:opacity-100 hover:text-primary hover:border-primary transition-all shadow-sm translate-x-1/2"
className="absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 z-10 flex items-center justify-center size-5 rounded-full bg-background border border-border text-muted-foreground cursor-pointer opacity-0 group-hover/rins:opacity-100 hover:text-primary hover:border-primary transition-all shadow-sm"
>
<PlusIcon className="size-3" />
</button>
@ -371,6 +373,15 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
</table>
</div>
{/* Add row button below the table */}
<div className="flex justify-center mt-2">
<Button variant="ghost" size="sm" className="text-xs text-muted-foreground cursor-pointer" onClick={addRow}>
<PlusIcon className="size-3.5" />
Add row
</Button>
</div>
</div>
{/* ============ FOOTER ============ */}
<div className="flex items-center justify-between px-4 py-3 border-t border-border">
<div className="flex items-center gap-3">
@ -381,6 +392,10 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
<PlusIcon className="size-3.5" />
Add row
</Button>
<Button variant="ghost" size="sm" className="text-xs text-muted-foreground cursor-pointer" onClick={addColumn}>
<PlusIcon className="size-3.5" />
Add column
</Button>
</div>
<div className="flex items-center gap-2">
<Button variant="ghost" className="cursor-pointer" onClick={() => onOpenChange(false)}>