diff --git a/CHANGELOG.md b/CHANGELOG.md index 265f9f160..8667e4071 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Changelog * 🎉 New `Table` prop, `headerRowRenderer`. ([@kaoDev](https://github.com/kaoDev) - [#600](https://github.com/bvaughn/react-virtualized/pull/600)) * 🎉 All `Table` event handlers now receive a named `event` params ([@paulbrom](https://github.com/paulbrom) - [#605](https://github.com/bvaughn/react-virtualized/pull/605)) * 🎉 Aria roles for `Table` improved to specify `role="row"` for table rows and `role="rowgroup"` for iner `Grid`. ([@jchen527](https://github.com/jchen527) - [#607](https://github.com/bvaughn/react-virtualized/pull/607)) +* 🐛 Calling `scrollToRow` for `List` or `Table` no longer potentially messes up horizontal scroll position. ([#603](https://github.com/bvaughn/react-virtualized/issues/603)) ##### 9.1.0 * 🎉 Public method `setScrollIndexes` added to `ArrowKeyStepper` to enable easier overrides of current/default focused cell. - ([@alexandro81](https://github.com/alexandro81) - [#592](https://github.com/bvaughn/react-virtualized/pull/592)) diff --git a/source/Grid/Grid.js b/source/Grid/Grid.js index aad2887b4..ee5d63f7d 100644 --- a/source/Grid/Grid.js +++ b/source/Grid/Grid.js @@ -355,11 +355,19 @@ export default class Grid extends PureComponent { columnIndex, rowIndex }) { + const { columnCount } = this.props + const props = this.props - this._updateScrollLeftForScrollToColumn({ - ...props, - scrollToColumn: columnIndex - }) + + // Don't adjust scroll offset for single-column grids (eg List, Table). + // This can cause a funky scroll offset because of the vertical scrollbar width. + if (columnCount > 1) { + this._updateScrollLeftForScrollToColumn({ + ...props, + scrollToColumn: columnIndex + }) + } + this._updateScrollTopForScrollToRow({ ...props, scrollToRow: rowIndex