Skip to content

Commit

Permalink
[Logs UI] Fix inaccuracy when jumping to a faraway time target (#40303)…
Browse files Browse the repository at this point in the history
… (#40696)
  • Loading branch information
Zacqary authored Jul 9, 2019
1 parent 99189bc commit 9271553
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,19 @@ export class VerticalScrollPanel<Child> extends React.PureComponent<
public getSnapshotBeforeUpdate(
prevProps: VerticalScrollPanelProps<Child>
): VerticalScrollPanelSnapshot<Child> {
if (prevProps.target !== this.props.target && this.props.target) {
/** Center the target if:
* 1. This component has just finished calculating its height after being first mounted
* 2. The target prop changes
*/
if (
(prevProps.height === 0 && this.props.height > 0) ||
(prevProps.target !== this.props.target && this.props.target)
) {
return {
scrollOffset: undefined,
scrollTarget: this.props.target,
};
} else {
} else if (this.props.height > 0) {
const visibleChildren = this.getVisibleChildren();

if (visibleChildren) {
Expand Down

0 comments on commit 9271553

Please sign in to comment.