Skip to content

Commit c44fc66

Browse files
anlyyaotdesign-bot
andauthored
fix(Stepper): filter invalid chars on input, validate & setValue on blur (#4484)
* fix(Stepper): filter invalid chars on input, validate & setValue on blur * chore: stash changelog [ci skip] --------- Co-authored-by: tdesign-bot <tdesign@tencent.com>
1 parent bbad157 commit c44fc66

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

packages/components/stepper/stepper.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ export default class Stepper extends SuperComponent {
135135
this.triggerEvent('focus', { value });
136136
},
137137

138+
/**
139+
* 输入过程中仅过滤非法字符并更新显示值,不做 min/max 边界约束。范围校验和 change 事件统一在 handleBlur 中处理
140+
*/
138141
handleInput(e) {
139142
const { value } = e.detail;
140143
// 允许输入空值
@@ -143,13 +146,8 @@ export default class Stepper extends SuperComponent {
143146
}
144147

145148
const formatted = this.filterIllegalChar(value);
146-
const newValue = this.format(formatted);
147149

148-
this.updateCurrentValue(this.data.integer ? newValue : formatted);
149-
150-
if (this.data.integer || /\.\d*[1-9]/.test(formatted)) {
151-
this.setValue(formatted);
152-
}
150+
this.updateCurrentValue(formatted);
153151
},
154152

155153
handleBlur(e) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
pr_number: 4484
3+
contributor: anlyyao
4+
---
5+
6+
- fix(Stepper): 调整手动输入逻辑,输入时仅过滤非法字符,范围校验&赋值移至失焦 @anlyyao ([#4484](https://github.com/Tencent/tdesign-miniprogram/pull/4484))

0 commit comments

Comments
 (0)