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.Number 输入框删完最后一个数字时不触发onChange的问题(此时返回null或undefined) #780

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sheinx",
"private": true,
"version": "3.4.6-beta.2",
"version": "3.4.6-beta.3",
"description": "A react library developed with sheinx",
"module": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
5 changes: 5 additions & 0 deletions packages/hooks/src/components/use-input/use-input-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ const useNumberFormat = (props: InputNumberProps) => {
setInternalInputValue(getStringValue(val));
if(typeof val === 'string'){
const num = parseFloat(val);
if(val === '') {
// 如果允许空值,则返回 null,否则返回 undefined
onChange?.(allowNull ? null : undefined);
return;
}
if(isNaN(num)) return
onChange?.(num);
}else{
Expand Down
7 changes: 7 additions & 0 deletions packages/shineout/src/input/__doc__/changelog.cn.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 3.4.6-beta.3
2024-11-04

### 🐞 BugFix

- `Input.Number` 输入框删完最后一个数字时不触发onChange的问题(此时返回null或undefined) ([#780](https://github.com/sheinsight/shineout-next/pull/780))

## 3.4.3
2024-10-14

Expand Down
7 changes: 6 additions & 1 deletion packages/shineout/src/input/__example__/03-number-1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
import React from 'react';
import { Input } from 'shineout';

const App: React.FC = () => <Input.Number width={300} />;
const App: React.FC = () => {

return <Input.Number width={300} onChange={v => {
console.log('Input.Number', v);
}} />
};

export default App;