Skip to content

Commit 1caede2

Browse files
authored
fix regression of scrollToRow (#78)
* fix regression of scrollToRow * don't set columnIndex in scrollToRow * update
1 parent 71b6557 commit 1caede2

File tree

5 files changed

+51
-2
lines changed

5 files changed

+51
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## NEXT VERSION
44

5+
- fix: `scrollToRow` doesn't work regression introduced in #73
6+
57
## v1.7.0 (2019-08-06)
68

79
- chore: remove the use of `Object.values`

src/BaseTable.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ class BaseTable extends React.PureComponent {
211211
this.table && this.table.scrollToRow(rowIndex, align);
212212
this.leftTable && this.leftTable.scrollToRow(rowIndex, align);
213213
this.rightTable && this.rightTable.scrollToRow(rowIndex, align);
214-
this.scrollToLeft(0);
215214
}
216215

217216
/**

src/GridTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class GridTable extends React.PureComponent {
4040
}
4141

4242
scrollToRow(rowIndex = 0, align = 'auto') {
43-
this.bodyRef && this.bodyRef.scrollToItem({ rowIndex, columnIndex: 0, align });
43+
this.bodyRef && this.bodyRef.scrollToItem({ rowIndex, align });
4444
}
4545

4646
renderRow(args) {

website/siteConfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,9 @@ module.exports = {
204204
title: 'Inline Editing',
205205
path: '/examples/inline-editing',
206206
},
207+
{
208+
title: 'Scroll Methods',
209+
path: '/examples/scroll-to',
210+
},
207211
],
208212
}

website/src/examples/scroll-to.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const columns = generateColumns(10)
2+
const data = generateData(columns, 500)
3+
4+
const Button = styled.button`
5+
padding: 4px 8px;
6+
margin: 10px;
7+
`
8+
9+
export default class App extends React.Component {
10+
setRef = ref => (this.table = ref)
11+
12+
render() {
13+
return (
14+
<>
15+
<Button onClick={() => this.table.scrollToRow(100, 'auto')}>
16+
scrollToRow(100, 'auto')
17+
</Button>
18+
<Button onClick={() => this.table.scrollToRow(200, 'start')}>
19+
scrollToRow(200, 'start')
20+
</Button>
21+
<Button onClick={() => this.table.scrollToRow(300, 'center')}>
22+
scrollToRow(300, 'center')
23+
</Button>
24+
<Button onClick={() => this.table.scrollToRow(400, 'end')}>
25+
scrollToRow(400, 'end')
26+
</Button>
27+
<Button onClick={() => this.table.scrollToLeft(400)}>
28+
scrollToLeft(400)
29+
</Button>
30+
<Button onClick={() => this.table.scrollToTop(400)}>
31+
scrollToTop(400)
32+
</Button>
33+
<Button
34+
onClick={() =>
35+
this.table.scrollToPosition({ scrollLeft: 200, scrollTop: 2000 })
36+
}
37+
>
38+
{'scrollToPosition({ scrollLeft: 200, scrollTop: 2000 })'}
39+
</Button>
40+
<Table ref={this.setRef} fixed columns={columns} data={data} />
41+
</>
42+
)
43+
}
44+
}

0 commit comments

Comments
 (0)