Skip to content

Commit 155d32f

Browse files
uyarnPengYYYYY
authored andcommitted
fix: clearable of datepicker and timepicker
1 parent 73d609d commit 155d32f

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/date-picker/date-picker.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ export default defineComponent({
533533
}
534534
return placeholderStr;
535535
},
536+
handleTInputFocus() {
537+
// TODO: 待改成select-input后删除
538+
// hack 在input聚焦时马上blur 避免出现输入光标
539+
(this.$refs.native as HTMLInputElement).blur();
540+
},
536541
},
537542
render() {
538543
// props
@@ -655,7 +660,6 @@ export default defineComponent({
655660
disabled={disabled}
656661
clearable={clearable}
657662
placeholder={this.getPlaceholderText()}
658-
readonly={!allowInput}
659663
allowInput={allowInput ? 1 : 0}
660664
size={size}
661665
inputProps={inputProps}
@@ -668,6 +672,7 @@ export default defineComponent({
668672
click={this.onClick}
669673
suffixIcon={suffixIcon}
670674
prefixIcon={prefixIcon}
675+
onFocus={this.handleTInputFocus}
671676
/>
672677
</div>
673678
</t-popup>

src/time-picker/time-picker.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ export default defineComponent({
299299
emitEvent(this, 'change', undefined);
300300
e.stopPropagation();
301301
},
302+
handleTInputFocus() {
303+
// TODO: 待改成select-input后删除
304+
// hack 在input聚焦时马上blur 避免出现输入光标
305+
(this.$refs.tInput as HTMLInputElement).blur();
306+
},
302307
renderInput() {
303308
const classes = [
304309
`${this.COMPONENT_NAME}__group`,
@@ -317,11 +322,12 @@ export default defineComponent({
317322
size={this.size}
318323
onClear={this.clear}
319324
clearable={this.clearable}
320-
readonly
321325
placeholder=" "
322326
value={this.time ? ' ' : undefined}
323327
class={this.isShowPanel ? this.STATUS.focused : ''}
324328
v-slots={slots}
329+
ref="tInput"
330+
onFocus={this.handleTInputFocus}
325331
></t-input>
326332
<input-items
327333
size={this.size}

src/time-picker/time-range-picker.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ export default defineComponent({
257257
emitEvent(this, 'change', values);
258258
isFunction(this.onChange) && this.onChange(values);
259259
},
260+
handleTInputFocus() {
261+
// TODO: 待改成select-input后删除
262+
// hack 在input聚焦时马上blur 避免出现输入光标
263+
(this.$refs.tInput as HTMLInputElement).blur();
264+
},
260265
renderInput() {
261266
const classes = [
262267
`${this.COMPONENT_NAME}__group`,
@@ -272,8 +277,9 @@ export default defineComponent({
272277
onClear={this.clear}
273278
clearable={this.clearable}
274279
placeholder=" "
275-
readonly
276280
value={!isEqual(this.time, TIME_PICKER_EMPTY) ? ' ' : undefined}
281+
ref="tInput"
282+
onFocus={this.handleTInputFocus}
277283
>
278284
<time-icon slot="suffix-icon"></time-icon>
279285
</t-input>

0 commit comments

Comments
 (0)