Skip to content

Commit c897d32

Browse files
zkwolftangjinzhou
authored andcommitted
fix: time-picker bug (#1176)
当使用backspace删除所有字符后,输入第一个字符控制台报错,并无字符显示
1 parent a678e3b commit c897d32

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

components/vc-time-picker/Header.jsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const Header = {
2828
currentSelectPanel: PropTypes.string,
2929
focusOnOpen: PropTypes.bool,
3030
// onKeyDown: PropTypes.func,
31-
showStr: PropTypes.bool.def(true),
3231
clearIcon: PropTypes.any,
3332
},
3433
data() {
@@ -70,7 +69,6 @@ const Header = {
7069
return;
7170
}
7271

73-
this.showStr = true;
7472
this.setState({
7573
str,
7674
});
@@ -192,14 +190,14 @@ const Header = {
192190
},
193191

194192
getInput() {
195-
const { prefixCls, placeholder, inputReadOnly, invalid, str, showStr } = this;
193+
const { prefixCls, placeholder, inputReadOnly, invalid, str } = this;
196194
const invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
197195
return (
198196
<input
199197
class={`${prefixCls}-input ${invalidClass}`}
200198
ref="input"
201199
onKeydown={this.onKeyDown}
202-
value={showStr ? str : ''}
200+
value={str}
203201
placeholder={placeholder}
204202
onInput={this.onInputChange}
205203
readOnly={!!inputReadOnly}

components/vc-time-picker/Panel.jsx

-8
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,13 @@ const Panel = {
5757
sValue: this.value,
5858
selectionRange: [],
5959
currentSelectPanel: '',
60-
showStr: true,
6160
};
6261
},
6362
watch: {
6463
value(val) {
6564
if (val) {
6665
this.setState({
6766
sValue: val,
68-
showStr: true,
69-
});
70-
} else {
71-
this.setState({
72-
showStr: false,
7367
});
7468
}
7569
},
@@ -132,7 +126,6 @@ const Panel = {
132126
inputReadOnly,
133127
sValue,
134128
currentSelectPanel,
135-
showStr,
136129
$listeners = {},
137130
} = this;
138131
const clearIcon = getComponentFromProp(this, 'clearIcon');
@@ -181,7 +174,6 @@ const Panel = {
181174
focusOnOpen={focusOnOpen}
182175
onKeydown={keydown}
183176
inputReadOnly={inputReadOnly}
184-
showStr={showStr}
185177
clearIcon={clearIcon}
186178
/>
187179
<Combobox

0 commit comments

Comments
 (0)