From 3922b741e98f39e659f99613fa6efe4a7cb7f5b3 Mon Sep 17 00:00:00 2001 From: Vitali Pinchuk <146737590+vitPinchuk@users.noreply.github.com> Date: Fri, 22 Nov 2024 04:44:24 +0300 Subject: [PATCH] Added type check for text area (#172) * add check to type * Update CHANGELOG.md --------- Co-authored-by: Mikhail Volkov --- CHANGELOG.md | 1 + .../EditableColumnEditorsRegistry.test.tsx | 16 ++++++++++++++++ .../EditableColumnEditorsRegistry.tsx | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 579344e..52b8c55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Updated group expand and collapse behavior (#161) - Added custom value to editable select field (#165) - Updated group expanding for empty cells (#169) +- Added type check for text area (#172) ## 1.7.0 (2024-11-16) diff --git a/src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.test.tsx b/src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.test.tsx index a11ce32..318a311 100644 --- a/src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.test.tsx +++ b/src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.test.tsx @@ -527,6 +527,22 @@ describe('editableColumnEditorsRegistry', () => { expect(onChange).toHaveBeenCalledWith('line updated'); }); + it('Should render control with a non-string type ', () => { + render( + getControlComponent({ + value: null, + config: createColumnEditConfig({ editor: { type: ColumnEditorType.TEXTAREA } }).editor, + }) + ); + + expect(controlSelectors.fieldTextarea()).toBeInTheDocument(); + expect(controlSelectors.fieldTextarea()).toHaveValue('null'); + + fireEvent.change(controlSelectors.fieldTextarea(), { target: { value: 'line updated' } }); + + expect(onChange).toHaveBeenCalledWith('line updated'); + }); + it('Should render control with replaced lines and replace line onChange correctly', () => { render( getControlComponent({ diff --git a/src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.tsx b/src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.tsx index e333e4d..7e2e169 100644 --- a/src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.tsx +++ b/src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.tsx @@ -56,7 +56,7 @@ export const editableColumnEditorsRegistry = createEditableColumnEditorsRegistry editor: () => null, control: ({ value, onChange, isSaving }) => (