Skip to content

Commit

Permalink
Added type check for text area (#172)
Browse files Browse the repository at this point in the history
* add check to type

* Update CHANGELOG.md

---------

Co-authored-by: Mikhail Volkov <[email protected]>
  • Loading branch information
vitPinchuk and mikhail-vl authored Nov 22, 2024
1 parent 5e95161 commit 3922b74
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const editableColumnEditorsRegistry = createEditableColumnEditorsRegistry
editor: () => null,
control: ({ value, onChange, isSaving }) => (
<TextArea
value={(value as string).replaceAll('\\n', '\n')}
value={typeof value === 'string' ? (value as string).replaceAll('\\n', '\n') : String(value)}
onChange={(event: ChangeEvent<HTMLTextAreaElement>) => {
onChange(event.target.value.replaceAll('\n', '\\n'));
}}
Expand Down

0 comments on commit 3922b74

Please sign in to comment.