Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(input): 修复 input 内 preValue 计算错误问题(#3347) #3427

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SaberA1ter
Copy link

@SaberA1ter SaberA1ter commented Jan 18, 2025

Types of changes

  • New feature
  • Bug fix
  • Enhancement
  • Component style change
  • Typescript definition change
  • Documentation change
  • Coding style change
  • Refactoring
  • Test cases
  • Continuous integration
  • Breaking change
  • Others

Background and context

#3347

虽然 issue 中提到的是 inputNumber 组件,但实际上这个错误发生在 input 组件中。

可以查看 demo:https://codesandbox.io/p/sandbox/floral-framework-jjvymj?file=%2Fsrc%2FApp.vue%3A23%2C1

复现流程:默认值是 123,输入一个 4,按回车键触发 change 事件,现在 input 显示 1234,也可以看到控制台输出,等三秒定时器将输入内容设置为 789,这时候再修改为 1234,按回车,不会触发 change 事件。(注意这个过程不要让输入框失去焦点)

Solution

原逻辑是在 input 组件聚焦及触发 change 事件时更新 preValue,现使用 watch 第二个参数 oldValue 进行更新。

How is the change tested?

Changelog

Component Changelog(CN) Changelog(EN) Related issues
input 修复 input 内 preValue 计算错误问题 Fix the preValue calculation error in the input component #3347

Checklist:

  • Test suite passes (npm run test)
  • Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others
    should be submitted to main branch)

Other information

Copy link

codesandbox bot commented Jan 18, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant