Skip to content
Merged
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
4 changes: 2 additions & 2 deletions packages/common/src/core/__tests__/slickGrid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7414,7 +7414,7 @@ describe('SlickGrid core file', () => {
expect(result).toEqual({ row: 1, cell: 1 });
});

it('should return { row:1, cell:1 } when clicked cell is second cell of second row with a frozenRow and frozenBottom is inside range', () => {
it('should return { row:2, cell:1 } when clicked cell is second cell of second row with a frozenRow and frozenBottom is inside range', () => {
grid = new SlickGrid<any, Column>(container, data, columns, { ...defaultOptions, enableCellNavigation: true, frozenRow: 3, frozenBottom: true });
const secondRowSlickCells = container.querySelectorAll('.slick-row:nth-child(2) .slick-cell');
const event = new CustomEvent('click');
Expand All @@ -7423,7 +7423,7 @@ describe('SlickGrid core file', () => {
Object.defineProperty(event, 'clientY', { writable: true, value: DEFAULT_COLUMN_HEIGHT * 1 + 5 });
const result = grid.getCellFromEvent(event);

expect(result).toEqual({ row: 1, cell: 1 });
expect(result).toEqual({ row: 2, cell: 1 });
});

it('should return null when using frozenRow that result into invalid row/cell number', () => {
Expand Down
9 changes: 7 additions & 2 deletions packages/common/src/core/slickGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6744,7 +6744,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
const isBottom = Utils.parents(cellNode, '.grid-canvas-bottom').length;

if (isBottom) {
rowOffset = this._options.frozenBottom ? (Utils.height(this._canvasTopL) as number) : this.frozenRowsHeight;
// same render-path offset as above: getFrozenRowOffset, not a live top-canvas measurement
rowOffset = this.getFrozenRowOffset(this.actualFrozenRow);
}

const x = targetEvent.clientX - c.left;
Expand Down Expand Up @@ -6888,7 +6889,11 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
const isBottom = Utils.parents(this.activeCellNode, '.grid-canvas-bottom').length;

if (this.hasFrozenRows && isBottom) {
rowOffset -= this._options.frozenBottom ? (Utils.height(this._canvasTopL) as number) : this.frozenRowsHeight;
// use the same offset the render path uses to place bottom-canvas rows
// (getFrozenRowOffset), not a live measurement of the top canvas — the two
// diverge in frozenBottom mode (e.g. small datasets) and hit-testing then
// resolves the wrong row
rowOffset -= this.getFrozenRowOffset(this.actualFrozenRow);
}

const cell = this.getCellFromPoint(activeCellOffset.left, Math.ceil(activeCellOffset.top) - rowOffset);
Expand Down
Loading