From f5cd5361ee4ee2bc24d46a3bde10b5f23fb63d7d Mon Sep 17 00:00:00 2001 From: Viktor Nagy Date: Tue, 28 May 2024 12:46:50 +0200 Subject: [PATCH 1/2] feat: allow comma in number field --- packages/sn-controls-react/src/fieldcontrols/number.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sn-controls-react/src/fieldcontrols/number.tsx b/packages/sn-controls-react/src/fieldcontrols/number.tsx index e642d2162..d93a6bafa 100644 --- a/packages/sn-controls-react/src/fieldcontrols/number.tsx +++ b/packages/sn-controls-react/src/fieldcontrols/number.tsx @@ -25,10 +25,10 @@ export const NumberField: React.FC) => { - setValue(e.target.value) + const inputValue = e.target.value.replace(/[^0-9.,]/g, '') + setValue(inputValue) props.fieldOnChange?.(props.settings.Name, e.target.value) } - /** * Returns steps value by decimal and step settings */ @@ -60,7 +60,7 @@ export const NumberField: React.FC Date: Tue, 11 Jun 2024 11:08:10 +0200 Subject: [PATCH 2/2] fix: test cases for number input --- .../sn-controls-react/test/__snapshots__/number.test.tsx.snap | 2 +- packages/sn-controls-react/test/number.test.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sn-controls-react/test/__snapshots__/number.test.tsx.snap b/packages/sn-controls-react/test/__snapshots__/number.test.tsx.snap index 704371c51..cbf517de5 100644 --- a/packages/sn-controls-react/test/__snapshots__/number.test.tsx.snap +++ b/packages/sn-controls-react/test/__snapshots__/number.test.tsx.snap @@ -53,7 +53,7 @@ exports[`Number field control in edit/new view should set all the props 1`] = ` onChange={[Function]} placeholder="0" required={true} - type="number" + type="text" value={7} /> diff --git a/packages/sn-controls-react/test/number.test.tsx b/packages/sn-controls-react/test/number.test.tsx index 7f8d35ccf..7dd4b781f 100644 --- a/packages/sn-controls-react/test/number.test.tsx +++ b/packages/sn-controls-react/test/number.test.tsx @@ -101,7 +101,7 @@ describe('Number field control', () => { const wrapper = shallow( , ) - wrapper.find(TextField).simulate('change', { target: { value: 2 } }) + wrapper.find(TextField).simulate('change', { target: { value: '2' } }) expect(fieldOnChange).toBeCalled() }) })