Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions ui/studio/grid/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ export function DataGrid(props: DataGridProps) {
});
const shouldEnablePreview = Boolean(
dragDropTarget.compatibleOverId &&
dragDropTarget.compatibleOverId !== activeId,
dragDropTarget.compatibleOverId !== activeId,
);
setIsColumnReorderPreviewEnabled((current) =>
current === shouldEnablePreview ? current : shouldEnablePreview,
Expand Down Expand Up @@ -1470,8 +1470,8 @@ export function DataGrid(props: DataGridProps) {
const text = hasRowSelection
? getSelectedRowClipboardText()
: hasCellSelection
? getSelectedClipboardText()
: getFocusedCellClipboardText();
? getSelectedClipboardText()
: getFocusedCellClipboardText();

if (!text) {
return;
Expand Down Expand Up @@ -2064,12 +2064,26 @@ export function DataGrid(props: DataGridProps) {
return;
}

selectSingleRowMode({ rowId, rowIndex, drag: isPrimaryButton });
clearNativeTextSelection();
clearCellSelectionState();

const nextSelection = { ...rowSelectionState };

if (nextSelection[rowId]) {
delete nextSelection[rowId];
} else {
nextSelection[rowId] = true;
}

setRowSelection(nextSelection);

rowSelectionDragRef.current = isPrimaryButton;
rowSelectionAnchorRef.current = rowIndex;
},
[
clearCellSelectionState,
clearNativeTextSelection,
rowSelectionState,
selectSingleRowMode,
setRowSelection,
],
);
Expand Down
23 changes: 19 additions & 4 deletions ui/studio/grid/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ColumnDef } from "@tanstack/react-table";
import { act } from "react";
import { type Mock, vi } from "vitest";

import { CheckboxTable } from "../../components/ui/checkbox-table";
import { TableHead } from "../../components/ui/table";
import { Cell, type CellProps } from "../cell/Cell";

Expand Down Expand Up @@ -58,14 +59,28 @@ export function createReadOnlyColumns(args?: {
enableSorting: false,
size: 35,
minSize: 35,
header() {
header({ table }) {
return (props: Omit<CellProps, "children" | "ref">) => (
<TableHead {...props} aria-label="Row selection spacer" />
<TableHead {...props} aria-label="Row selection spacer">
<div className="flex items-center justify-center h-full w-full">
<CheckboxTable
checked={table.getIsAllRowsSelected()}
className="pointer-events-none h-4 w-4"
/>
</div>
</TableHead>
);
},
cell() {
cell({ row }) {
return (props: Omit<CellProps, "children" | "ref">) => (
<Cell data-select="true" {...props} />
<Cell data-select="true" {...props}>
<div className="flex items-center justify-center h-full w-full">
<CheckboxTable
checked={row.getIsSelected()}
className="pointer-events-none h-4 w-4"
/>
</div>
</Cell>
);
},
};
Expand Down
25 changes: 21 additions & 4 deletions ui/studio/views/sql/SqlView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { createSqlEditorSchemaFromIntrospection } from "../../../../data/sql-edi
import { getTopLevelSqlStatementAtCursor } from "../../../../data/sql-statements";
import { Button } from "../../../components/ui/button";
import { Input } from "../../../components/ui/input";
import { CheckboxTable } from "../../../components/ui/checkbox-table";
import { TableHead, TableRow } from "../../../components/ui/table";
import { useColumnPinning } from "../../../hooks/use-column-pinning";
import { useIntrospection } from "../../../hooks/use-introspection";
Expand Down Expand Up @@ -103,15 +104,31 @@ const SQL_ROW_SELECTION_COLUMN_DEF = {
size: 35,
minSize: 35,
header({ table }) {
void table;
return (props: Omit<CellProps, "children" | "ref">) => {
return <TableHead {...props} aria-label="Row selection spacer" />;
return (
<TableHead {...props} aria-label="Row selection spacer">
<div className="flex items-center justify-center h-full w-full">
<CheckboxTable
checked={table.getIsAllRowsSelected()}
className="pointer-events-none h-4 w-4"
/>
</div>
</TableHead>
);
};
},
cell({ row }) {
void row;
return (props: Omit<CellProps, "children" | "ref">) => {
return <Cell data-select="true" {...props} />;
return (
<Cell data-select="true" {...props}>
<div className="flex items-center justify-center h-full w-full">
<CheckboxTable
checked={row.getIsSelected()}
className="pointer-events-none h-4 w-4"
/>
</div>
</Cell>
);
};
},
} satisfies ColumnDef<Record<string, unknown>>;
Expand Down
25 changes: 21 additions & 4 deletions ui/studio/views/table/ActiveTableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "../../../components/ui/dropdown-menu";
import { CheckboxTable } from "../../../components/ui/checkbox-table";
import { TableHead } from "../../../components/ui/table";
import { useActiveTableInsert } from "../../../hooks/use-active-table-insert";
import { useActiveTableQuery } from "../../../hooks/use-active-table-query";
Expand Down Expand Up @@ -1516,15 +1517,31 @@ export function ActiveTableView(_props: ViewProps) {
size: 35,
minSize: 35,
header({ table }) {
void table;
return (props: Omit<CellProps, "children" | "ref">) => {
return <TableHead {...props} aria-label="Row selection spacer" />;
return (
<TableHead {...props} aria-label="Row selection spacer">
<div className="flex items-center justify-center h-full w-full">
<CheckboxTable
checked={table.getIsAllRowsSelected()}
className="pointer-events-none h-4 w-4"
/>
</div>
</TableHead>
);
};
},
cell({ row }) {
void row;
return (props: Omit<CellProps, "children" | "ref">) => {
return <Cell data-select="true" {...props} />;
return (
<Cell data-select="true" {...props}>
<div className="flex items-center justify-center h-full w-full">
<CheckboxTable
checked={row.getIsSelected()}
className="pointer-events-none h-4 w-4"
/>
</div>
</Cell>
);
};
},
},
Expand Down