Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ function getSelectedTooltip(
return (
!tt.if ||
(ifColumnId(tt.if, id) &&
ifRowIndex(tt.if, row) &&
ifRowIndex(
tt.if,
virtualized.indices[row - virtualized.offset.rows]
) &&
ifFilter(
tt.if,
virtualized.data[row - virtualized.offset.rows]
Expand Down
11 changes: 5 additions & 6 deletions components/dash-table/src/dash-table/handlers/cellEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ export const handleEnter = (
idx: number,
i: number
) => {
const {setState, virtualized, visibleColumns} = propsFn();
const {setState, visibleColumns} = propsFn();

setState({
currentTooltip: {
header: false,
id: visibleColumns[i].id,
row: virtualized.indices[idx - virtualized.offset.rows]
row: idx
}
});
};
Expand Down Expand Up @@ -202,15 +202,14 @@ export const handleMove = (
idx: number,
i: number
) => {
const {currentTooltip, setState, virtualized, visibleColumns} = propsFn();
const {currentTooltip, setState, visibleColumns} = propsFn();

const c = visibleColumns[i];
const realIdx = virtualized.indices[idx - virtualized.offset.rows];

if (
currentTooltip &&
currentTooltip.id === c.id &&
currentTooltip.row === realIdx &&
currentTooltip.row === idx &&
!currentTooltip.header
) {
return;
Expand All @@ -220,7 +219,7 @@ export const handleMove = (
currentTooltip: {
header: false,
id: c.id,
row: realIdx
row: idx
}
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {expect} from 'chai';

import {handleEnter, handleMove} from 'dash-table/handlers/cellEvents';

describe('cell events - tooltip row index with pagination', () => {
it('uses the provided row index when entering a cell', () => {
let state: any;
const propsFn = () =>
({
setState: (next: any) => {
state = next;
},
visibleColumns: [{id: 'Description'}],
virtualized: {
indices: [5, 6, 7, 8, 9],
offset: {rows: 0, columns: 0}
}
}) as any;

handleEnter(propsFn, 6, 0);

expect(state.currentTooltip.row).to.equal(6);
expect(state.currentTooltip.id).to.equal('Description');
expect(state.currentTooltip.header).to.equal(false);
});

it('uses the provided row index when moving between cells', () => {
let state: any;
const propsFn = () =>
({
currentTooltip: {
header: false,
id: 'Description',
row: 5
},
setState: (next: any) => {
state = next;
},
visibleColumns: [{id: 'Description'}],
virtualized: {
indices: [5, 6, 7, 8, 9],
offset: {rows: 0, columns: 0}
}
}) as any;

handleMove(propsFn, 6, 0);

expect(state.currentTooltip.row).to.equal(6);
expect(state.currentTooltip.id).to.equal('Description');
expect(state.currentTooltip.header).to.equal(false);
});
});
Loading