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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## NEXT VERSION

- fix: `scrollToRow` doesn't work regression introduced in #73

## v1.7.0 (2019-08-06)

- chore: remove the use of `Object.values`
Expand Down
1 change: 0 additions & 1 deletion src/BaseTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ class BaseTable extends React.PureComponent {
this.table && this.table.scrollToRow(rowIndex, align);
this.leftTable && this.leftTable.scrollToRow(rowIndex, align);
this.rightTable && this.rightTable.scrollToRow(rowIndex, align);
this.scrollToLeft(0);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/GridTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GridTable extends React.PureComponent {
}

scrollToRow(rowIndex = 0, align = 'auto') {
this.bodyRef && this.bodyRef.scrollToItem({ rowIndex, columnIndex: 0, align });
this.bodyRef && this.bodyRef.scrollToItem({ rowIndex, align });
}

renderRow(args) {
Expand Down
4 changes: 4 additions & 0 deletions website/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,9 @@ module.exports = {
title: 'Inline Editing',
path: '/examples/inline-editing',
},
{
title: 'Scroll Methods',
path: '/examples/scroll-to',
},
],
}
44 changes: 44 additions & 0 deletions website/src/examples/scroll-to.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const columns = generateColumns(10)
const data = generateData(columns, 500)

const Button = styled.button`
padding: 4px 8px;
margin: 10px;
`

export default class App extends React.Component {
setRef = ref => (this.table = ref)

render() {
return (
<>
<Button onClick={() => this.table.scrollToRow(100, 'auto')}>
scrollToRow(100, 'auto')
</Button>
<Button onClick={() => this.table.scrollToRow(200, 'start')}>
scrollToRow(200, 'start')
</Button>
<Button onClick={() => this.table.scrollToRow(300, 'center')}>
scrollToRow(300, 'center')
</Button>
<Button onClick={() => this.table.scrollToRow(400, 'end')}>
scrollToRow(400, 'end')
</Button>
<Button onClick={() => this.table.scrollToLeft(400)}>
scrollToLeft(400)
</Button>
<Button onClick={() => this.table.scrollToTop(400)}>
scrollToTop(400)
</Button>
<Button
onClick={() =>
this.table.scrollToPosition({ scrollLeft: 200, scrollTop: 2000 })
}
>
{'scrollToPosition({ scrollLeft: 200, scrollTop: 2000 })'}
</Button>
<Table ref={this.setRef} fixed columns={columns} data={data} />
</>
)
}
}