Skip to content

Commit 3922b74

Browse files
Added type check for text area (#172)
* add check to type * Update CHANGELOG.md --------- Co-authored-by: Mikhail Volkov <[email protected]>
1 parent 5e95161 commit 3922b74

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Updated group expand and collapse behavior (#161)
1010
- Added custom value to editable select field (#165)
1111
- Updated group expanding for empty cells (#169)
12+
- Added type check for text area (#172)
1213

1314
## 1.7.0 (2024-11-16)
1415

src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,22 @@ describe('editableColumnEditorsRegistry', () => {
527527
expect(onChange).toHaveBeenCalledWith('line updated');
528528
});
529529

530+
it('Should render control with a non-string type ', () => {
531+
render(
532+
getControlComponent({
533+
value: null,
534+
config: createColumnEditConfig({ editor: { type: ColumnEditorType.TEXTAREA } }).editor,
535+
})
536+
);
537+
538+
expect(controlSelectors.fieldTextarea()).toBeInTheDocument();
539+
expect(controlSelectors.fieldTextarea()).toHaveValue('null');
540+
541+
fireEvent.change(controlSelectors.fieldTextarea(), { target: { value: 'line updated' } });
542+
543+
expect(onChange).toHaveBeenCalledWith('line updated');
544+
});
545+
530546
it('Should render control with replaced lines and replace line onChange correctly', () => {
531547
render(
532548
getControlComponent({

src/components/editors/EditableColumnEditor/EditableColumnEditorsRegistry.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const editableColumnEditorsRegistry = createEditableColumnEditorsRegistry
5656
editor: () => null,
5757
control: ({ value, onChange, isSaving }) => (
5858
<TextArea
59-
value={(value as string).replaceAll('\\n', '\n')}
59+
value={typeof value === 'string' ? (value as string).replaceAll('\\n', '\n') : String(value)}
6060
onChange={(event: ChangeEvent<HTMLTextAreaElement>) => {
6161
onChange(event.target.value.replaceAll('\n', '\\n'));
6262
}}

0 commit comments

Comments
 (0)