Skip to content

Commit

Permalink
fix: Fixed custom field submission on Enter key press
Browse files Browse the repository at this point in the history
- Resolves an issue where pressing the "Enter" key while adding a custom field in the settings was triggering an error.
- Modified the handling of form submission to ensure that the custom field is added successfully whether the "Submit" button
  is clicked or the "Enter" key is pressed.
- Ensured all the modified lines are covered by tests and no other functionality is affected.

Signed-off-by: Akhilender <[email protected]>
  • Loading branch information
akhilender-bongirwar committed Jan 31, 2024
1 parent c756a73 commit 66c614e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ describe('Testing Save Button', () => {
expect(
screen.queryByText('Failed to add custom field')
).toBeInTheDocument();
await wait();
userEvent.type(screen.getByTestId('customFieldInput'), 'Age{enter}');
await wait();
expect(
screen.queryByText('Failed to add custom field')
).toBeInTheDocument();
});

test('Testing Typing Organization Custom Field Name', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const OrgProfileFieldSettings = (): any => {
setCustomFieldData({ type: '', name: '' });
refetch();
} catch (error) {
toast.success((error as Error).message);
toast.error((error as Error).message);
}
};

Expand Down Expand Up @@ -133,6 +133,12 @@ const OrgProfileFieldSettings = (): any => {
name: event.target.value,
});
}}
onKeyDown={(event) => {
if (event.key === 'Enter') {
event.preventDefault();
handleSave();
}
}}
/>
</div>

Expand Down

0 comments on commit 66c614e

Please sign in to comment.