[Logs UI] Fix initial accuracy of logs minimap click (#48826) (#49202)

* [Logs UI] Fix initial accuracy of logs minimap click

* Fix aberrant request to loadEntriesAfter when using minimap
This commit is contained in:
Zacqary Adam Xeper 2019-10-24 13:32:04 -05:00 committed by GitHub
parent 329f1c248d
commit 5cedccdc6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -80,7 +80,8 @@ export class LogMinimap extends React.Component<LogMinimapProps, LogMinimapState
}
public handleClick = (event: MouseEvent) => {
const { svgPosition } = this.state;
if (!this.dragTargetArea) return;
const svgPosition = this.dragTargetArea.getBoundingClientRect();
const clickedYPosition = event.clientY - svgPosition.top;
const clickedTime = Math.floor(this.getYScale().invert(clickedYPosition));
this.setState({

View file

@ -155,7 +155,7 @@ export class VerticalScrollPanel<Child> extends React.PureComponent<
} = this;
if (scrollRef.current === null || !target || childDimensions.size <= 0) {
return;
return false;
}
const targetDimensions = childDimensions.get(target);
@ -166,15 +166,20 @@ export class VerticalScrollPanel<Child> extends React.PureComponent<
// opposed to being in direct response to user input
this.nextScrollEventFromCenterTarget = true;
scrollRef.current.scrollTop = targetDimensions.top + targetOffset - scrollViewHeight / 2;
return true;
}
return false;
};
public handleUpdatedChildren = (target: Child | undefined, offset: number | undefined) => {
this.updateChildDimensions();
let centerTargetWillReportChildren = false;
if (!!target) {
this.centerTarget(target, offset);
centerTargetWillReportChildren = this.centerTarget(target, offset);
}
if (!centerTargetWillReportChildren) {
this.reportVisibleChildren();
}
this.reportVisibleChildren();
};
public componentDidMount() {