Skip to content

Commit

Permalink
feat: focus first cell on column add
Browse files Browse the repository at this point in the history
  • Loading branch information
Amelia Wattenberger committed Jan 20, 2022
1 parent 2249cc6 commit 11ee519
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ const HeaderWrapper = function (props: CellProps) {
focusedRowIndex,
cellTypes,
isEditable,
handleFocusedCellPositionChange,
onHeaderCellChange,
onHeaderDelete,
onHeaderAdd,
Expand Down Expand Up @@ -819,6 +820,13 @@ const HeaderWrapper = function (props: CellProps) {
const onHeaderDeleteLocal = () => {
onHeaderDelete(columnName);
}
const onHeaderAddLocal = (newColumnName: string) => {
onHeaderAdd(newColumnName);
handleFocusedCellPositionChange([
0,
columnNames.length,
])
}

return (
<HeaderWrapperComputed
Expand All @@ -841,7 +849,7 @@ const HeaderWrapper = function (props: CellProps) {
isEditable={isEditable}
onChange={onHeaderCellChangeLocal}
onDelete={onHeaderDeleteLocal}
onAdd={onHeaderAdd}
onAdd={onHeaderAddLocal}
onSort={handleSortChange}
onSticky={() => handleStickyColumnNameChange(columnName)}
onFilterChange={(value: FilterValue) => {
Expand Down

0 comments on commit 11ee519

Please sign in to comment.