From a11ac150085c34b20fc117c34aa17fec14efe6da Mon Sep 17 00:00:00 2001 From: Bob Fanger Date: Thu, 1 Jul 2021 12:11:00 +0200 Subject: [PATCH] fix: Don't overwrite value while typing (#1082) Fixes #316 --- .../lazy-app/Compress/Options/Range/index.tsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/client/lazy-app/Compress/Options/Range/index.tsx b/src/client/lazy-app/Compress/Options/Range/index.tsx index da6e37e2..8b1150e3 100644 --- a/src/client/lazy-app/Compress/Options/Range/index.tsx +++ b/src/client/lazy-app/Compress/Options/Range/index.tsx @@ -6,10 +6,13 @@ import './custom-els/RangeInput'; import { linkRef } from 'shared/prerendered-app/util'; interface Props extends preact.JSX.HTMLAttributes {} -interface State {} +interface State { + textFocused: boolean; +} export default class Range extends Component { rangeWc?: RangeInputElement; + inputEl?: HTMLInputElement; private onTextInput = (event: Event) => { const input = event.target as HTMLInputElement; @@ -23,10 +26,19 @@ export default class Range extends Component { ); }; - render(props: Props) { + private onTextFocus = () => { + this.setState({ textFocused: true }); + }; + + private onTextBlur = () => { + this.setState({ textFocused: false }); + }; + + render(props: Props, state: State) { const { children, ...otherProps } = props; const { value, min, max, step } = props; + const textValue = state.textFocused ? this.inputEl!.value : value; return ( );