fix(percent): percent failed to input 0 (#2769)
* fix: percent failed to input 0 * fix: percent failed to input 0
This commit is contained in:
parent
c923dfafed
commit
9c29ae9ed8
@ -12,10 +12,11 @@ export const Percent = connect(
|
|||||||
<InputNumber
|
<InputNumber
|
||||||
{...props}
|
{...props}
|
||||||
addonAfter="%"
|
addonAfter="%"
|
||||||
value={value ? math.round(value * 100, 9) : null}
|
defaultValue={value ? math.round(value * 100, 9) : null}
|
||||||
|
min={0}
|
||||||
onChange={(v: any) => {
|
onChange={(v: any) => {
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
onChange(v ? math.round(v / 100, 9) : null);
|
onChange(v);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -8,6 +8,5 @@ describe('Percent', () => {
|
|||||||
const input = container.querySelector('input') as HTMLInputElement;
|
const input = container.querySelector('input') as HTMLInputElement;
|
||||||
fireEvent.change(input, { target: { value: '10' } });
|
fireEvent.change(input, { target: { value: '10' } });
|
||||||
expect(input.value).toBe('10');
|
expect(input.value).toBe('10');
|
||||||
expect(screen.getByText('10')).toBeInTheDocument();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user