Skip to content

Commit 2d1b84b

Browse files
committed
fix row hover in horizontal layout and release version major
1 parent bf15040 commit 2d1b84b

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

examples/src/pages/tests/horizontal-layout/test.page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@ const columns: InfiniteTablePropColumns<Developer> = {
2929
type: 'number',
3030
defaultWidth: 100,
3131
style: {
32-
background: 'rgba(255, 99, 71, 0.4)',
32+
// background: 'rgba(255, 99, 71, 0.4)',
3333
},
3434
},
3535
canDesign: {
3636
field: 'canDesign',
3737
defaultWidth: 200,
3838
style: {
39-
background: 'rgba(211, 119, 171, 0.3)',
39+
// background: 'rgba(211, 119, 171, 0.3)',
4040
},
4141
},
4242
salary: {
4343
field: 'salary',
4444
type: 'number',
4545
defaultWidth: 300,
4646
style: {
47-
background: 'rgba(55, 99, 171, 0.5)',
47+
// background: 'rgba(55, 99, 171, 0.5)',
4848
},
4949
},
5050
firstName: {
5151
field: 'firstName',
5252
style: {
53-
background: 'rgb(111 255 72 / 48%)',
53+
// background: 'rgb(111 255 72 / 48%)',
5454
},
5555
},
5656
// age: {

source/src/components/HeadlessTable/ReactHeadlessTableRenderer.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { GridCellInterface } from './GridCellInterface';
3131

3232
import { setFilter, setIntersection } from '../../utils/setUtils';
3333
import { ListRowInterface, ListRowManager } from './ListRowManager';
34+
import type { HorizontalLayoutMatrixBrain } from '../VirtualBrain/HorizontalLayoutMatrixBrain';
3435

3536
const ITEM_POSITION_WITH_TRANSFORM = true;
3637

@@ -1270,14 +1271,25 @@ export class GridRenderer extends Logger {
12701271
}
12711272

12721273
protected onMouseEnterNotBound = (event: React.MouseEvent<HTMLElement>) => {
1273-
const rowIndex = Number(event.currentTarget.dataset.rowIndex);
1274+
const rowIndex = this.getMatrixRowIndexFromElement(event.currentTarget);
12741275
this.onMouseEnter(rowIndex);
12751276
};
12761277
protected onMouseLeaveNotBound = (event: React.MouseEvent<HTMLElement>) => {
1277-
const rowIndex = Number(event.currentTarget.dataset.rowIndex);
1278+
const rowIndex = this.getMatrixRowIndexFromElement(event.currentTarget);
12781279
this.onMouseLeave(rowIndex);
12791280
};
12801281

1282+
private getMatrixRowIndexFromElement(element: HTMLElement): number {
1283+
const renderedRowIndex = Number(element.dataset.rowIndex);
1284+
1285+
if (this.brain.isHorizontalLayoutBrain) {
1286+
return (
1287+
this.brain as unknown as HorizontalLayoutMatrixBrain
1288+
).getRowIndexInPage(renderedRowIndex);
1289+
}
1290+
return renderedRowIndex;
1291+
}
1292+
12811293
protected renderCellAt(
12821294
rowIndex: number,
12831295
colIndex: number,

0 commit comments

Comments
 (0)