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

feat: InputNumber support stringMode #29373

Merged
merged 16 commits into from
Feb 22, 2021
Merged

feat: InputNumber support stringMode #29373

merged 16 commits into from
Feb 22, 2021

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Feb 19, 2021

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English InputNumber support stringMode for high precision step. value in control out of range shows warning style instead of changing it. Dynamic update min & max will not trigger onChange anymore.
🇨🇳 Chinese InputNumber 添加 stringMode 属性以支持高精度 stepvalue 受控并超出范围时展示警告样式而不是强制改值。动态修改 minmax 不再触发 onChange 事件。

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2021

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2021

Size Change: +130 B (0%)

Total Size: 834 kB

Filename Size Change
./dist/antd-with-locales.min.js 336 kB +50 B (0%)
./dist/antd.compact.min.css 67.1 kB +18 B (0%)
./dist/antd.dark.min.css 68.5 kB +23 B (0%)
./dist/antd.min.css 67.1 kB +18 B (0%)
./dist/antd.min.js 296 kB +21 B (0%)

compressed-size-action

@afc163 afc163 changed the title [WIP] feat: InputNumber support stingMode [WIP] feat: InputNumber support stringMode Feb 20, 2021
@zombieJ zombieJ changed the title [WIP] feat: InputNumber support stringMode feat: InputNumber support stringMode Feb 20, 2021
@zombieJ zombieJ marked this pull request as ready for review February 22, 2021 03:33
defaultValue="1"
min="0"
max="10"
step="0.00000000000000000000000000000903"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

例子里搞一个这么极端的 step 不太容易看。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有什么建议吗?不够小的话看不出和原本的差别……

Copy link
Member

@afc163 afc163 Feb 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是原来的 demo 保留,另建一个高精度的?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我想法是不建议用户再用原来的方式了,所以特地换掉了这个 Demo。让人看到要小数就用 stringMode。steps 可以缩小,但是不建议原来的 Demo 加回来。

Copy link
Member

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 里面转一下,成本有点大。

Copy link
Member Author

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 的,还是希望用户就按照最准确的来会比较好。

Copy link
Member

@kerm1it kerm1it Feb 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我的意思是 stringMode 应该定位的是高精度,对于低精度的用户来说,不使用 stringMode 保持原来的用法也可以实现,不然只要使用小数就得使用 stringMode,还得对值的类型做转换。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

毕竟使用高精度的用户不是很多,不应该为了少数人的需求,让其他大部分的用户改变用法。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以前的用法也是支持的,只是不需要留两个 Demo 来展示精度处理。在 Demo 里我倾向于只留一个高精度的,用户学过去绝对不会错。低精度的 basic demo 其实已经满足抄的需求了。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接 step="0.00000000000001" 好了,抄起来不会有问题,也方便演示。

@afc163
Copy link
Member

afc163 commented Feb 22, 2021

图片

挂了

@zombieJ
Copy link
Member Author

zombieJ commented Feb 22, 2021

@zombieJ
Copy link
Member Author

zombieJ commented Feb 22, 2021

我回头 CI 加个 retry

@zombieJ zombieJ merged commit bec5a08 into feature Feb 22, 2021
@zombieJ zombieJ deleted the stringNumber branch February 22, 2021 14:07
@zombieJ zombieJ mentioned this pull request Feb 28, 2021
15 tasks
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.

3 participants