From b00912d1f80b85cc3f931a4d91fb6b95b9e4bfe6 Mon Sep 17 00:00:00 2001 From: martincupela Date: Fri, 11 Jul 2025 14:57:33 +0200 Subject: [PATCH 1/2] fix: distinguish non-submit form buttons --- src/components/Dialog/FormDialog.tsx | 1 + src/components/MessageInput/EditMessageForm.tsx | 1 + src/components/Poll/PollCreationDialog/OptionFieldSet.tsx | 3 ++- .../Poll/PollCreationDialog/PollCreationDialogControls.tsx | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Dialog/FormDialog.tsx b/src/components/Dialog/FormDialog.tsx index a19d13404..4cc1525d6 100644 --- a/src/components/Dialog/FormDialog.tsx +++ b/src/components/Dialog/FormDialog.tsx @@ -139,6 +139,7 @@ export const FormDialog = < diff --git a/src/components/MessageInput/EditMessageForm.tsx b/src/components/MessageInput/EditMessageForm.tsx index 33075d858..aa224f633 100644 --- a/src/components/MessageInput/EditMessageForm.tsx +++ b/src/components/MessageInput/EditMessageForm.tsx @@ -58,6 +58,7 @@ export const EditMessageForm = () => { className='str-chat__edit-message-cancel' data-testid='cancel-button' onClick={cancel} + type='button' > {t('Cancel')} diff --git a/src/components/Poll/PollCreationDialog/OptionFieldSet.tsx b/src/components/Poll/PollCreationDialog/OptionFieldSet.tsx index 26e178a28..be0d7d8f7 100644 --- a/src/components/Poll/PollCreationDialog/OptionFieldSet.tsx +++ b/src/components/Poll/PollCreationDialog/OptionFieldSet.tsx @@ -65,7 +65,8 @@ export const OptionFieldSet = () => { }); }} onKeyUp={(event) => { - if (event.key === 'Enter') { + const isFocusedLastOptionField = i === options.length - 1; + if (event.key === 'Enter' && !isFocusedLastOptionField) { const nextInputId = options[i + 1].id; document.getElementById(nextInputId)?.focus(); } diff --git a/src/components/Poll/PollCreationDialog/PollCreationDialogControls.tsx b/src/components/Poll/PollCreationDialog/PollCreationDialogControls.tsx index 00ea0787a..cf8bc9301 100644 --- a/src/components/Poll/PollCreationDialog/PollCreationDialogControls.tsx +++ b/src/components/Poll/PollCreationDialog/PollCreationDialogControls.tsx @@ -22,6 +22,7 @@ export const PollCreationDialogControls = ({ messageComposer.pollComposer.initState(); close(); }} + type='button' > {t('Cancel')} From 30ea925eb28c84057622f4685a85a2d22dd78931 Mon Sep 17 00:00:00 2001 From: martincupela Date: Fri, 11 Jul 2025 15:21:21 +0200 Subject: [PATCH 2/2] test: disable drafts at the end of each draft enabling test --- .../__tests__/ThreadMessageInput.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/components/MessageInput/__tests__/ThreadMessageInput.test.js b/src/components/MessageInput/__tests__/ThreadMessageInput.test.js index f31762777..663d892e5 100644 --- a/src/components/MessageInput/__tests__/ThreadMessageInput.test.js +++ b/src/components/MessageInput/__tests__/ThreadMessageInput.test.js @@ -172,6 +172,11 @@ describe('MessageInput in Thread', () => { customClient, }); expect(getDraftSpy).toHaveBeenCalledTimes(1); + await act(() => { + customClient.setMessageComposerSetupFunction(({ composer }) => { + composer.updateConfig({ drafts: { enabled: false } }); + }); + }); }); it('prevents querying if composition is not empty', async () => { const { customChannel, customClient, getDraftSpy } = await setup(); @@ -186,6 +191,11 @@ describe('MessageInput in Thread', () => { customClient, }); expect(getDraftSpy).not.toHaveBeenCalled(); + await act(() => { + customClient.setMessageComposerSetupFunction(({ composer }) => { + composer.updateConfig({ drafts: { enabled: false } }); + }); + }); }); it('prevents querying if not rendered inside a thread', async () => { const { customChannel, customClient, getDraftSpy } = await setup(); @@ -200,6 +210,11 @@ describe('MessageInput in Thread', () => { customClient, }); expect(getDraftSpy).not.toHaveBeenCalled(); + await act(() => { + customClient.setMessageComposerSetupFunction(({ composer }) => { + composer.updateConfig({ drafts: { enabled: false } }); + }); + }); }); it('prevents querying if drafts are disabled (default)', async () => { const { customChannel, customClient, getDraftSpy } = await setup();