From 184c72a2e107b599e0856d83b6dd11f5e8d19302 Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Mon, 9 Dec 2019 12:49:07 -0300 Subject: [PATCH] Fix option not being checked when numeric ids are used --- .../src/input/RadioButtonGroupInput.spec.tsx | 22 +++++++++++++++++++ .../src/input/RadioButtonGroupInputItem.tsx | 11 ++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/ra-ui-materialui/src/input/RadioButtonGroupInput.spec.tsx b/packages/ra-ui-materialui/src/input/RadioButtonGroupInput.spec.tsx index ae1c8603782..83bf5d8ded4 100644 --- a/packages/ra-ui-materialui/src/input/RadioButtonGroupInput.spec.tsx +++ b/packages/ra-ui-materialui/src/input/RadioButtonGroupInput.spec.tsx @@ -57,6 +57,28 @@ describe('', () => { ).toBeTruthy(); }); + it('should work correctly when ids are numbers', () => { + const choices = [ + { id: 1, name: 'VISA' }, + { id: 2, name: 'Mastercard' }, + ]; + const { getByLabelText } = render( +
( + + )} + /> + ); + const input = getByLabelText('Mastercard') as HTMLInputElement; + expect(input.checked).toBe(false); + fireEvent.click(input); + expect(input.checked).toBe(true); + }); + it('should use optionValue as value identifier', () => { const { getByLabelText } = render( } + control={ + onChange(value)} + {...inputProps} + /> + } /> ); };