Use innerRef to blur input
parent
6925570467
commit
a7d0c5ba53
|
@ -104,12 +104,6 @@ const factory = (ProgressBar, Input) => {
|
||||||
events.removeEventsFromDocument(this.getKeyboardEvents());
|
events.removeEventsFromDocument(this.getKeyboardEvents());
|
||||||
}
|
}
|
||||||
|
|
||||||
getInput() {
|
|
||||||
return this.inputNode && this.inputNode.getWrappedInstance
|
|
||||||
? this.inputNode.getWrappedInstance()
|
|
||||||
: this.inputNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
getKeyboardEvents() {
|
getKeyboardEvents() {
|
||||||
return {
|
return {
|
||||||
keydown: this.handleKeyDown,
|
keydown: this.handleKeyDown,
|
||||||
|
@ -159,13 +153,13 @@ const factory = (ProgressBar, Input) => {
|
||||||
const { ARROW_DOWN, ARROW_UP, ENTER, ESC } = KEYS;
|
const { ARROW_DOWN, ARROW_UP, ENTER, ESC } = KEYS;
|
||||||
|
|
||||||
if (disabled) return;
|
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_UP) this.addToValue(step);
|
||||||
if (event.keyCode === ARROW_DOWN) this.addToValue(-step);
|
if (event.keyCode === ARROW_DOWN) this.addToValue(-step);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMouseDown = (event) => {
|
handleMouseDown = (event) => {
|
||||||
if (this.state.inputFocused) this.getInput().blur();
|
if (this.state.inputFocused) this.inputNode.blur();
|
||||||
events.addEventsToDocument(this.getMouseEventMap());
|
events.addEventsToDocument(this.getMouseEventMap());
|
||||||
this.start(events.getMousePosition(event));
|
this.start(events.getMousePosition(event));
|
||||||
events.pauseEvent(event);
|
events.pauseEvent(event);
|
||||||
|
@ -203,7 +197,7 @@ const factory = (ProgressBar, Input) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
handleTouchStart = (event) => {
|
handleTouchStart = (event) => {
|
||||||
if (this.state.inputFocused) this.getInput().blur();
|
if (this.state.inputFocused) this.inputNode.blur();
|
||||||
this.start(events.getTouchPosition(event));
|
this.start(events.getTouchPosition(event));
|
||||||
events.addEventsToDocument(this.getTouchEventMap());
|
events.addEventsToDocument(this.getTouchEventMap());
|
||||||
events.pauseEvent(event);
|
events.pauseEvent(event);
|
||||||
|
@ -268,7 +262,7 @@ const factory = (ProgressBar, Input) => {
|
||||||
if (!this.props.editable) return undefined;
|
if (!this.props.editable) return undefined;
|
||||||
return (
|
return (
|
||||||
<Input
|
<Input
|
||||||
ref={(node) => { this.inputNode = node; }}
|
innerRef={(node) => { this.inputNode = node; }}
|
||||||
className={this.props.theme.input}
|
className={this.props.theme.input}
|
||||||
disabled={this.props.disabled}
|
disabled={this.props.disabled}
|
||||||
onFocus={this.handleInputFocus}
|
onFocus={this.handleInputFocus}
|
||||||
|
|
Loading…
Reference in New Issue