Fix bug that sets the range input to the resolution (#10227)

* Fix bug that sets the range input to the resolution

Signed-off-by: Julius Volz <julius.volz@gmail.com>

* Address review comments

Signed-off-by: Julius Volz <julius.volz@gmail.com>
pull/10232/head
Julius Volz 2022-01-31 17:56:56 +01:00 committed by GitHub
parent 9fde6edbf5
commit 3c9faa25bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -58,7 +58,9 @@ class GraphControls extends Component<GraphControlsProps> {
};
changeRangeInput = (range: number): void => {
this.setCurrentRangeValue(formatDuration(range));
if (this.rangeRef.current !== null) {
this.rangeRef.current.value = formatDuration(range);
}
};
increaseRange = (): void => {
@ -81,18 +83,18 @@ class GraphControls extends Component<GraphControlsProps> {
}
};
changeResolutionInput = (resolution: number | null): void => {
if (this.resolutionRef.current !== null) {
this.resolutionRef.current.value = resolution !== null ? resolution.toString() : '';
}
};
componentDidUpdate(prevProps: GraphControlsProps): void {
if (prevProps.range !== this.props.range) {
this.changeRangeInput(this.props.range);
}
if (prevProps.resolution !== this.props.resolution) {
this.setCurrentRangeValue(this.props.resolution !== null ? this.props.resolution.toString() : '');
}
}
setCurrentRangeValue(value: string): void {
if (this.rangeRef.current) {
this.rangeRef.current.value = value;
this.changeResolutionInput(this.props.resolution);
}
}