diff --git a/package.json b/package.json index 5364ad9186..9916f0eab6 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "react-dnd-html5-backend": "^16.0.1", "react-dom": "^18.1.0", "react-router-dom": "^6.11.1", - "rollup": "^3.26.2", + "rollup": "^4.0.2", "rollup-plugin-postcss": "^4.0.2", "typescript": "~5.2.2", "vite": "^4.4.9", diff --git a/src/Cell.tsx b/src/Cell.tsx index d0a26f28bd..cb04228a69 100644 --- a/src/Cell.tsx +++ b/src/Cell.tsx @@ -2,7 +2,7 @@ import { memo } from 'react'; import { css } from '@linaria/core'; import { useRovingTabIndex } from './hooks'; -import { createCellEvent, getCellClassname, getCellStyle, isCellEditable } from './utils'; +import { createCellEvent, getCellClassname, getCellStyle, isCellEditableUtil } from './utils'; import type { CellRendererProps } from './types'; const cellCopied = css` @@ -51,7 +51,7 @@ function Cell({ }, typeof cellClass === 'function' ? cellClass(row) : cellClass ); - const isEditable = isCellEditable(column, row); + const isEditable = isCellEditableUtil(column, row); function selectCellWrapper(openEditor?: boolean) { selectCell({ rowIdx, idx: column.idx }, openEditor); diff --git a/src/DataGrid.tsx b/src/DataGrid.tsx index f2cb7a8fb1..9d1b554cff 100644 --- a/src/DataGrid.tsx +++ b/src/DataGrid.tsx @@ -838,7 +838,8 @@ function DataGrid( return; } - const column = columns[selectedPosition.idx]; + const { idx, rowIdx } = selectedPosition; + const column = columns[idx]; if (column.renderEditCell == null || column.editable === false) { return; } @@ -847,10 +848,12 @@ function DataGrid( return ( extends Pick, 'rows' | 'onRowsChange gridRowStart: number; column: CalculatedColumn; columnWidth: number | string; + maxColIdx: number; + isLastRow: boolean; selectedPosition: SelectCellState; latestDraggedOverRowIdx: React.MutableRefObject; isCellEditable: (position: Position) => boolean; @@ -50,6 +52,8 @@ export default function DragHandle({ rows, column, columnWidth, + maxColIdx, + isLastRow, selectedPosition, latestDraggedOverRowIdx, isCellEditable, @@ -118,19 +122,26 @@ export default function DragHandle({ } } - const colSpan = column.colSpan?.({ type: 'ROW', row: rows[rowIdx] }) ?? 1; - const style = getCellStyle(column, colSpan); + function getStyle(): React.CSSProperties { + const colSpan = column.colSpan?.({ type: 'ROW', row: rows[rowIdx] }) ?? 1; + const { insetInlineStart, ...style } = getCellStyle(column, colSpan); + const marginEnd = 'calc(var(--rdg-drag-handle-size) * -0.5 + 1px)'; + const isLastColumn = column.idx + colSpan - 1 === maxColIdx; + + return { + ...style, + gridRowStart, + marginInlineEnd: isLastColumn ? undefined : marginEnd, + marginBlockEnd: isLastRow ? undefined : marginEnd, + insetInlineStart: insetInlineStart + ? `calc(${insetInlineStart} + ${columnWidth}px + var(--rdg-drag-handle-size) * -0.5 - 1px)` + : undefined + }; + } return (
( keyGetter: unknown diff --git a/src/utils/selectedCellUtils.ts b/src/utils/selectedCellUtils.ts index 956aabcef2..a3142da8ce 100644 --- a/src/utils/selectedCellUtils.ts +++ b/src/utils/selectedCellUtils.ts @@ -20,10 +20,11 @@ export function isSelectedCellEditable({ }: IsSelectedCellEditableOpts): boolean { const column = columns[selectedPosition.idx]; const row = rows[selectedPosition.rowIdx]; - return isCellEditable(column, row); + return isCellEditableUtil(column, row); } -export function isCellEditable(column: CalculatedColumn, row: R): boolean { +// https://github.com/vercel/next.js/issues/56480 +export function isCellEditableUtil(column: CalculatedColumn, row: R): boolean { return ( column.renderEditCell != null && (typeof column.editable === 'function' ? column.editable(row) : column.editable) !== false