diff --git a/src/core/client/ui/hocs/withKeyboardFocus.tsx b/src/core/client/ui/hocs/withKeyboardFocus.tsx index 179ff2302..230ce8f77 100644 --- a/src/core/client/ui/hocs/withKeyboardFocus.tsx +++ b/src/core/client/ui/hocs/withKeyboardFocus.tsx @@ -19,9 +19,9 @@ const withKeyboardFocus: DefaultingInferableComponentEnhancer< > = hoistStatics( (BaseComponent: React.ComponentType) => { class WithKeyboardFocus extends React.Component { + private lastMouseDownTime: number = 0; public state = { keyboardFocus: false, - lastMouseDownTime: 0, }; private handleFocus: React.EventHandler> = event => { @@ -29,7 +29,7 @@ const withKeyboardFocus: DefaultingInferableComponentEnhancer< this.props.onFocus(event); } const now = new Date().getTime(); - if (now - this.state.lastMouseDownTime > 750) { + if (now - this.lastMouseDownTime > 750) { this.setState({ keyboardFocus: true }); } }; @@ -45,7 +45,7 @@ const withKeyboardFocus: DefaultingInferableComponentEnhancer< if (this.props.onMouseDown) { this.props.onMouseDown(event); } - this.setState({ lastMouseDownTime: new Date().getTime() }); + this.lastMouseDownTime = new Date().getTime(); }; public render() { diff --git a/src/core/client/ui/hocs/withMouseHover.tsx b/src/core/client/ui/hocs/withMouseHover.tsx index a37fb015f..235cedfb7 100644 --- a/src/core/client/ui/hocs/withMouseHover.tsx +++ b/src/core/client/ui/hocs/withMouseHover.tsx @@ -19,16 +19,16 @@ const withMouseHover: DefaultingInferableComponentEnhancer< > = hoistStatics( (BaseComponent: React.ComponentType) => { class WithMouseHover extends React.Component { + private lastTouchEndTime = 0; public state = { mouseHover: false, - lastTouchEndTime: 0, }; private handleTouchEnd: React.EventHandler> = event => { if (this.props.onTouchEnd) { this.props.onTouchEnd(event); } - this.setState({ lastTouchEndTime: new Date().getTime() }); + this.lastTouchEndTime = new Date().getTime(); }; private handleMouseOver: React.EventHandler> = event => { @@ -36,7 +36,7 @@ const withMouseHover: DefaultingInferableComponentEnhancer< this.props.onMouseOver(event); } const now = new Date().getTime(); - if (now - this.state.lastTouchEndTime > 750) { + if (now - this.lastTouchEndTime > 750) { this.setState({ mouseHover: true }); } };