diff --git a/packages/ra-ui-materialui/src/input/NumberInput.spec.tsx b/packages/ra-ui-materialui/src/input/NumberInput.spec.tsx index b1842309504..72fcc55c2f4 100644 --- a/packages/ra-ui-materialui/src/input/NumberInput.spec.tsx +++ b/packages/ra-ui-materialui/src/input/NumberInput.spec.tsx @@ -7,7 +7,6 @@ import { AdminContext } from '../AdminContext'; import { SaveButton } from '../button'; import { SimpleForm, Toolbar } from '../form'; import { required } from 'ra-core'; -import { Format, Parse } from './NumberInput.stories'; describe('', () => { const defaultProps = { @@ -199,7 +198,7 @@ describe('', () => { }); describe('format and parse', () => { - it('should get the same value as injected value', async () => { + it('should get the same value as injected value ', async () => { const onSubmit = jest.fn(); render( @@ -291,31 +290,6 @@ describe('', () => { }); expect(onSubmit.mock.calls[0][0].views).toBeNull(); }); - - it('should use custom format function prop', async () => { - render(); - - const input = screen.getByLabelText('resources.posts.fields.views'); - fireEvent.change(input, { target: { value: 5.6356487 } }); - - await waitFor(() => { - expect((input as HTMLInputElement).value).toEqual('5.6356487'); - expect( - (screen.getByDisplayValue('5.64') as HTMLInputElement).value - ).toEqual('5.64'); - }); - }); - - it('should use custom parse function prop', async () => { - render(); - - const input = screen.getByLabelText('Parse to two decimal'); - fireEvent.change(input, { target: { value: 5.6356487 } }); - - await waitFor(() => { - expect((input as HTMLInputElement).value).toEqual('5.64'); - }); - }); }); describe('onChange event', () => { diff --git a/packages/ra-ui-materialui/src/input/NumberInput.stories.tsx b/packages/ra-ui-materialui/src/input/NumberInput.stories.tsx index 01cb5e2f77b..b2b217c1dd6 100644 --- a/packages/ra-ui-materialui/src/input/NumberInput.stories.tsx +++ b/packages/ra-ui-materialui/src/input/NumberInput.stories.tsx @@ -313,49 +313,3 @@ export const FieldState = () => ( ); - -export const Format = () => ( - - - - - - isNaN(v) ? 0 : Number(parseFloat(v).toFixed(2)) - } - disabled - /> - - - - -); - -export const Parse = () => ( - - - - (v ? String(v) : '0')} - parse={v => { - const float = Number(parseFloat(v).toFixed(2)); - return isNaN(float) ? null : float; - }} - /> - - - - -); diff --git a/packages/ra-ui-materialui/src/input/NumberInput.tsx b/packages/ra-ui-materialui/src/input/NumberInput.tsx index 0f1cdbfd587..5de6eb18ef6 100644 --- a/packages/ra-ui-materialui/src/input/NumberInput.tsx +++ b/packages/ra-ui-materialui/src/input/NumberInput.tsx @@ -47,8 +47,6 @@ export const NumberInput = ({ isRequired, } = useInput({ defaultValue, - format, - parse, onBlur, resource, source, @@ -60,7 +58,7 @@ export const NumberInput = ({ // This is a controlled input that renders directly the string typed by the user. // This string is converted to a number on change, and stored in the form state, - // but that number is not displayed. + // but that number is not not displayed. // This is to allow transitory values like '1.0' that will lead to '1.02' // text typed by the user and displayed in the input, unparsed