diff --git a/packages/common/src/core/__tests__/slickGrid.spec.ts b/packages/common/src/core/__tests__/slickGrid.spec.ts index 3c940fa8e..e788faa8f 100644 --- a/packages/common/src/core/__tests__/slickGrid.spec.ts +++ b/packages/common/src/core/__tests__/slickGrid.spec.ts @@ -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(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'); @@ -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', () => { diff --git a/packages/common/src/core/slickGrid.ts b/packages/common/src/core/slickGrid.ts index 46c31047d..d51a698b7 100755 --- a/packages/common/src/core/slickGrid.ts +++ b/packages/common/src/core/slickGrid.ts @@ -6744,7 +6744,8 @@ export class SlickGrid = Column, 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; @@ -6888,7 +6889,11 @@ export class SlickGrid = Column, 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);