Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logs UI] Fix inaccuracy when jumping to a faraway time target #40303

Merged
merged 3 commits into from
Jul 9, 2019
Merged
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
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