diff --git a/CHANGELOG.md b/CHANGELOG.md index 54067f05..be2b4235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/src/BaseTable.js b/src/BaseTable.js index 73a4de27..f4760580 100644 --- a/src/BaseTable.js +++ b/src/BaseTable.js @@ -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); } /** diff --git a/src/GridTable.js b/src/GridTable.js index 7e6b59b5..a1b83616 100644 --- a/src/GridTable.js +++ b/src/GridTable.js @@ -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) { diff --git a/website/siteConfig.js b/website/siteConfig.js index 12776a45..6995bbe5 100644 --- a/website/siteConfig.js +++ b/website/siteConfig.js @@ -204,5 +204,9 @@ module.exports = { title: 'Inline Editing', path: '/examples/inline-editing', }, + { + title: 'Scroll Methods', + path: '/examples/scroll-to', + }, ], } diff --git a/website/src/examples/scroll-to.js b/website/src/examples/scroll-to.js new file mode 100644 index 00000000..b7fb7dd7 --- /dev/null +++ b/website/src/examples/scroll-to.js @@ -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 ( + <> + + + + + + + + + + ) + } +}