Skip to content

Commit

Permalink
[@mantine/core] NumberInput: Fix incorrect removeTrailingZeros defaul…
Browse files Browse the repository at this point in the history
…t prop value (#2621)

* [@mantine/core] NumberInput: make 'removeTrailingZeros' false by default

* [@mantine/core] NumberInput: make 'removeTrailingZeros' false by default

* [@mantine/core] NumberInput: make 'removeTrailingZeros' false by default

* [@mantine/core] NumberInput: make 'removeTrailingZeros' false by default, test fix
  • Loading branch information
PointSingularity committed Oct 4, 2022
1 parent f530697 commit 2f28569
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/mantine-core/src/NumberInput/NumberInput.test.tsx
Expand Up @@ -141,6 +141,16 @@ describe('@mantine/core/NumberInput', () => {
expect(spy).toHaveBeenLastCalledWith(6.123);
});

it('supports removing trailing zeros and decimal separator with precision', async () => {
const spy = jest.fn();
render(<NumberInput precision={8} removeTrailingZeros onChange={spy} />);
await enterText('6.00000000');
expect(spy).toHaveBeenLastCalledWith(6);
blurInput();
expectValue('6');
expect(spy).toHaveBeenLastCalledWith(6);
});

it('sets state to min if input is empty and is incremented/decremented', async () => {
const spy = jest.fn();
const { container } = render(<NumberInput max={10} min={0} step={6} onChange={spy} />);
Expand Down
2 changes: 1 addition & 1 deletion src/mantine-core/src/NumberInput/NumberInput.tsx
Expand Up @@ -117,7 +117,7 @@ const defaultProps: Partial<NumberInputProps> = {
size: 'sm',
precision: 0,
noClampOnBlur: false,
removeTrailingZeros: true,
removeTrailingZeros: false,
formatter: defaultFormatter,
parser: defaultParser,
type: 'text',
Expand Down

0 comments on commit 2f28569

Please sign in to comment.