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

Feature/新增非法输入警告 #409

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

huangminjianxx
Copy link

[English Template / 英文模板]

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

#34987

💡 需求背景和解决方案

📝 更新日志

语言 更新描述
🇺🇸 英文 The border turns red when the user enters a value that exceeds the boundary value or when the entered value is not a pure number
🇨🇳 中文 当用户输入的值超过边界值或者输入的值不是一个纯数字时,边框变红

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@vercel
Copy link

vercel bot commented Apr 13, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/react-component/input-number/FPrAgAiS3nyMyxvgJA3fUxbxYqyf
✅ Preview: https://input-number-git-fork-huangminjianxx-feature-react-component.vercel.app

@codecov
Copy link

codecov bot commented Apr 13, 2022

Codecov Report

Merging #409 (97e2e7d) into master (d3de147) will increase coverage by 0.02%.
The diff coverage is 100.00%.

❗ Current head 97e2e7d differs from pull request most recent head a72c815. Consider uploading reports for the commit a72c815 to get more accurate results

@@            Coverage Diff             @@
##           master     #409      +/-   ##
==========================================
+ Coverage   97.76%   97.79%   +0.02%     
==========================================
  Files           9        9              
  Lines         448      453       +5     
  Branches      116      117       +1     
==========================================
+ Hits          438      443       +5     
  Misses         10       10              
Impacted Files Coverage Δ
src/InputNumber.tsx 98.44% <100.00%> (+0.04%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link

@hydraZty hydraZty left a comment

Choose a reason for hiding this comment

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

输入负值的过程一般会先输入'-',最好做下兼容

@@ -399,8 +401,17 @@ const InputNumber = React.forwardRef(
collectInputValue(inputRef.current.value);
};

const judgeData = (inputNumberValue: string) => {

Choose a reason for hiding this comment

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

感觉这个方法跟 isInvalidate isInRange 是重复的

Copy link
Author

Choose a reason for hiding this comment

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

👌,我下午再更改一下提上来。

Copy link
Author

Choose a reason for hiding this comment

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

isInvalidate的作用是判断是否为空或者判断该值是否是一个数字,isInRange的作用是判断输入值是否在区间范围内,貌似可以用这两个方法结合起来去取代judgeData;
但这两个方法是decimalValue的静态方法,在用户输入的时候,decimalValue拿不到最新的值,比如原本输入框是5,我再输入一个5,在input的onChange事件中,decimalValue的拿到的值是5而不是55,这一点你觉得有什么比较好的解决方法吗?

Choose a reason for hiding this comment

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

可以用 inputValue,那个是实时的。

@vercel
Copy link

vercel bot commented Apr 21, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
input-number ✅ Ready (Inspect) Visit Preview Apr 21, 2022 at 7:41AM (UTC)

@@ -531,7 +540,7 @@ const InputNumber = React.forwardRef(
[`${prefixCls}-disabled`]: disabled,
[`${prefixCls}-readonly`]: readOnly,
[`${prefixCls}-not-a-number`]: decimalValue.isNaN(),

Choose a reason for hiding this comment

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

非数字其实应该在此处判断,更符合语义,不过这个 css 类名没写样式。需要在 assets\index.less L19 加上 &-not-a-number

@hydraZty
Copy link

写了个用 inputValue 的版本
FYI

@afc163
Copy link
Member

afc163 commented May 26, 2023

@zombieJ 来 CR 一下?

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