Skip to content

Commit

Permalink
Fix: controlled focussed cell not kept in focus
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Balucha authored and filipbalucha committed Jun 28, 2024
1 parent 7b93dfd commit 7dc859f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/table/src/tableHotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,16 @@ export class TableHotkeys {
this.props = props;
}

public setState(state: TableState) {
this.state = state;
public setState(newState: TableState) {
if (
newState.focusedCell != null &&
(this.state.focusedCell == null || this.state.focusedCell !== newState.focusedCell)
) {
// Ensure controlled focused cell is scrolled into view
this.scrollBodyToFocusedCell(newState.focusedCell);
}

this.state = newState;
}

// Selection
Expand Down Expand Up @@ -295,6 +303,8 @@ export class TableHotkeys {
return;
}

// The `viewportRect`'s origin does _not_ include frozen cells but the cumulative cell heights / widths _do_.
// So, there is a mismatch in origins that we fix this way (for now).
const frozenRowsHeight = this.grid.getCumulativeHeightBefore(this.state.numFrozenRowsClamped);
const frozenColumnsWidth = this.grid.getCumulativeWidthBefore(this.state.numFrozenColumnsClamped);

Expand Down

0 comments on commit 7dc859f

Please sign in to comment.