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: setZoom only keeps 2 decimal places #191

Closed
wants to merge 1 commit into from

Conversation

puxiao
Copy link

@puxiao puxiao commented Sep 28, 2024

@F-star
Copy link
Owner

F-star commented Sep 29, 2024

不能这样改。zoom 需要支持可以改成位数很小的,输入框只是显示的时候截断了。

问题在于失焦的时候,对比逻辑不对,对比的是传入的 12.34567% 和输入框得当前值 12%,发现不同,所以更新为 12。期待的是不更新 zoom,所以对比的应该是传入值 12%,和输入框的当前值。

@F-star F-star closed this Sep 30, 2024
@puxiao
Copy link
Author

puxiao commented Oct 1, 2024

现在把事件写在了 onBlur 上就注定了你无法真的监控输入框的值是否发生了变化。
例如假设我们现在百分号也支持两位小数点,即 zoom 为 0.1234567 时百分号显示为 12.34%,那么在最终对比时一定是会拿 0.1234 与 输入框中的值 12.34% 来对比的,对比结果一定是不一样的。
那你可以说再增加一个变量用来记录用户是否修改了输入框,也会存在问题:假设用户手工输入了 12.34%,那是不是当 onBlur 时也会触发 zoom 的变化?可在用户角度来看他实际上并没有修改值啊,只是把值重复输入了一遍而已。

所以问题的根源是要对 NumberInput 做一次彻底改造,抛弃 onBlur。

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.

2 participants