diff --git a/package.json b/package.json index 21238dd..2539d89 100644 --- a/package.json +++ b/package.json @@ -39,17 +39,17 @@ "@rollup/plugin-terser": "0.4.4", "@rollup/plugin-typescript": "12.1.1", "@testing-library/react": "16.0.1", - "@types/node": "22.8.2", + "@types/node": "22.8.7", "@types/react": "18.3.12", "@types/react-dom": "18.3.1", "@vitest/coverage-v8": "2.1.4", - "eslint": "9.13.0", + "eslint": "9.14.0", "eslint-plugin-react": "7.37.2", "http-server": "14.1.1", "jsdom": "25.0.1", - "tslib": "2.8.0", + "tslib": "2.8.1", "typescript": "5.6.3", - "typescript-eslint": "8.12.1", + "typescript-eslint": "8.13.0", "vitest": "2.1.4" }, "peerDependencies": { diff --git a/src/HighTable.tsx b/src/HighTable.tsx index 5f1ca95..a325af3 100644 --- a/src/HighTable.tsx +++ b/src/HighTable.tsx @@ -25,6 +25,7 @@ interface TableProps { cacheKey?: string // used to persist column widths overscan?: number // number of rows to fetch outside of the viewport padding?: number // number of padding rows to render outside of the viewport + focus?: boolean // focus table on mount (default true) onDoubleClickCell?: (col: number, row: number) => void onMouseDownCell?: (event: React.MouseEvent, col: number, row: number) => void onError?: (error: Error) => void @@ -90,6 +91,7 @@ export default function HighTable({ cacheKey, overscan = 20, padding = 20, + focus = true, onDoubleClickCell, onMouseDownCell, onError = console.error, @@ -126,7 +128,7 @@ export default function HighTable({ if (isNaN(start)) throw new Error('invalid start row ' + start) if (isNaN(end)) throw new Error('invalid end row ' + end) - if (end - start > 1000) throw new Error('too many rows to fetch ' + (end - start)) + if (end - start > 1000) throw new Error('attempted to render too many rows ' + (end - start) + ' table must be contained in a scrollable div') const offsetTop = Math.max(0, start - padding) * rowHeight @@ -235,8 +237,10 @@ export default function HighTable({ // focus table on mount so arrow keys work useEffect(() => { - tableRef.current?.focus() - }, []) + if (focus) { + tableRef.current?.focus() + } + }, [focus]) // reset dataReady when data changes so that columns will auto-resize useEffect(() => {