-
-
Notifications
You must be signed in to change notification settings - Fork 50.8k
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
feat: InputNumber support stringMode #29373
Conversation
Size Change: +130 B (0%) Total Size: 834 kB
|
58f2b7c
to
9a147b8
Compare
defaultValue="1" | ||
min="0" | ||
max="10" | ||
step="0.00000000000000000000000000000903" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
例子里搞一个这么极端的 step 不太容易看。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有什么建议吗?不够小的话看不出和原本的差别……
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是原来的 demo 保留,另建一个高精度的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我想法是不建议用户再用原来的方式了,所以特地换掉了这个 Demo。让人看到要小数就用 stringMode
。steps 可以缩小,但是不建议原来的 Demo 加回来。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stringMode
返回的值是 string 类型,用户如果只想用1位小数,使用 stringMode
就得在 onChange
里面转一下,成本有点大。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
js 里 1.1 + 0.1
其实也有精度问题,rc-input-number
里根据 steps
做了截取。但是这个其实也挺 magic 的,还是希望用户就按照最准确的来会比较好。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我的意思是 stringMode
应该定位的是高精度,对于低精度的用户来说,不使用 stringMode
保持原来的用法也可以实现,不然只要使用小数就得使用 stringMode
,还得对值的类型做转换。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
毕竟使用高精度的用户不是很多,不应该为了少数人的需求,让其他大部分的用户改变用法。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以前的用法也是支持的,只是不需要留两个 Demo 来展示精度处理。在 Demo 里我倾向于只留一个高精度的,用户学过去绝对不会错。低精度的 basic demo 其实已经满足抄的需求了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接 step="0.00000000000001"
好了,抄起来不会有问题,也方便演示。
components/config-provider/__tests__/__snapshots__/components.test.js.snap
Show resolved
Hide resolved
= =! https://github.com/ant-design/ant-design/runs/1951163957?check_suite_focus=true Surge upload 挂了…… |
我回头 CI 加个 retry |
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
💡 Background and solution
📝 Changelog
stringMode
for high precisionstep
.value
in control out of range shows warning style instead of changing it. Dynamic updatemin
&max
will not triggeronChange
anymore.stringMode
属性以支持高精度step
。value
受控并超出范围时展示警告样式而不是强制改值。动态修改min
和max
不再触发onChange
事件。☑️ Self Check before Merge