Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions packages/components/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export default class Stepper extends SuperComponent {
this.triggerEvent('focus', { value });
},

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

const formatted = this.filterIllegalChar(value);
const newValue = this.format(formatted);

this.updateCurrentValue(this.data.integer ? newValue : formatted);

if (this.data.integer || /\.\d*[1-9]/.test(formatted)) {
this.setValue(formatted);
}
this.updateCurrentValue(formatted);
},

handleBlur(e) {
Expand Down
6 changes: 6 additions & 0 deletions packages/tdesign-miniprogram/.changelog/pr-4484.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
pr_number: 4484
contributor: anlyyao
---

- fix(Stepper): 调整手动输入逻辑,输入时仅过滤非法字符,范围校验&赋值移至失焦 @anlyyao ([#4484](https://github.com/Tencent/tdesign-miniprogram/pull/4484))
Loading