From a7d0c5ba53d4e1b6ed75a97aa803313e6a4760d8 Mon Sep 17 00:00:00 2001 From: rubenmoya Date: Mon, 29 Jan 2018 20:47:44 +0100 Subject: [PATCH] Use innerRef to blur input --- components/slider/Slider.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/components/slider/Slider.js b/components/slider/Slider.js index 7c21d4d5..3e25b945 100644 --- a/components/slider/Slider.js +++ b/components/slider/Slider.js @@ -104,12 +104,6 @@ const factory = (ProgressBar, Input) => { events.removeEventsFromDocument(this.getKeyboardEvents()); } - getInput() { - return this.inputNode && this.inputNode.getWrappedInstance - ? this.inputNode.getWrappedInstance() - : this.inputNode; - } - getKeyboardEvents() { return { keydown: this.handleKeyDown, @@ -159,13 +153,13 @@ const factory = (ProgressBar, Input) => { const { ARROW_DOWN, ARROW_UP, ENTER, ESC } = KEYS; if (disabled) return; - if ([ENTER, ESC].includes(event.keyCode)) this.getInput().blur(); + if ([ENTER, ESC].includes(event.keyCode)) this.inputNode.blur(); if (event.keyCode === ARROW_UP) this.addToValue(step); if (event.keyCode === ARROW_DOWN) this.addToValue(-step); }; handleMouseDown = (event) => { - if (this.state.inputFocused) this.getInput().blur(); + if (this.state.inputFocused) this.inputNode.blur(); events.addEventsToDocument(this.getMouseEventMap()); this.start(events.getMousePosition(event)); events.pauseEvent(event); @@ -203,7 +197,7 @@ const factory = (ProgressBar, Input) => { }; handleTouchStart = (event) => { - if (this.state.inputFocused) this.getInput().blur(); + if (this.state.inputFocused) this.inputNode.blur(); this.start(events.getTouchPosition(event)); events.addEventsToDocument(this.getTouchEventMap()); events.pauseEvent(event); @@ -268,7 +262,7 @@ const factory = (ProgressBar, Input) => { if (!this.props.editable) return undefined; return ( { this.inputNode = node; }} + innerRef={(node) => { this.inputNode = node; }} className={this.props.theme.input} disabled={this.props.disabled} onFocus={this.handleInputFocus}