fix: time-picker bug (#1176)

当使用backspace删除所有字符后,输入第一个字符控制台报错,并无字符显示
pull/1248/head
zkwolf 2019-09-29 18:10:23 +08:00 committed by tangjinzhou
parent a678e3b550
commit c897d32a00
2 changed files with 2 additions and 12 deletions

View File

@ -28,7 +28,6 @@ const Header = {
currentSelectPanel: PropTypes.string, currentSelectPanel: PropTypes.string,
focusOnOpen: PropTypes.bool, focusOnOpen: PropTypes.bool,
// onKeyDown: PropTypes.func, // onKeyDown: PropTypes.func,
showStr: PropTypes.bool.def(true),
clearIcon: PropTypes.any, clearIcon: PropTypes.any,
}, },
data() { data() {
@ -70,7 +69,6 @@ const Header = {
return; return;
} }
this.showStr = true;
this.setState({ this.setState({
str, str,
}); });
@ -192,14 +190,14 @@ const Header = {
}, },
getInput() { getInput() {
const { prefixCls, placeholder, inputReadOnly, invalid, str, showStr } = this; const { prefixCls, placeholder, inputReadOnly, invalid, str } = this;
const invalidClass = invalid ? `${prefixCls}-input-invalid` : ''; const invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
return ( return (
<input <input
class={`${prefixCls}-input ${invalidClass}`} class={`${prefixCls}-input ${invalidClass}`}
ref="input" ref="input"
onKeydown={this.onKeyDown} onKeydown={this.onKeyDown}
value={showStr ? str : ''} value={str}
placeholder={placeholder} placeholder={placeholder}
onInput={this.onInputChange} onInput={this.onInputChange}
readOnly={!!inputReadOnly} readOnly={!!inputReadOnly}

View File

@ -57,7 +57,6 @@ const Panel = {
sValue: this.value, sValue: this.value,
selectionRange: [], selectionRange: [],
currentSelectPanel: '', currentSelectPanel: '',
showStr: true,
}; };
}, },
watch: { watch: {
@ -65,11 +64,6 @@ const Panel = {
if (val) { if (val) {
this.setState({ this.setState({
sValue: val, sValue: val,
showStr: true,
});
} else {
this.setState({
showStr: false,
}); });
} }
}, },
@ -132,7 +126,6 @@ const Panel = {
inputReadOnly, inputReadOnly,
sValue, sValue,
currentSelectPanel, currentSelectPanel,
showStr,
$listeners = {}, $listeners = {},
} = this; } = this;
const clearIcon = getComponentFromProp(this, 'clearIcon'); const clearIcon = getComponentFromProp(this, 'clearIcon');
@ -181,7 +174,6 @@ const Panel = {
focusOnOpen={focusOnOpen} focusOnOpen={focusOnOpen}
onKeydown={keydown} onKeydown={keydown}
inputReadOnly={inputReadOnly} inputReadOnly={inputReadOnly}
showStr={showStr}
clearIcon={clearIcon} clearIcon={clearIcon}
/> />
<Combobox <Combobox