Skip to content

Commit bdc3c3e

Browse files
authored
fix: distinguish non-submit form buttons (#2769)
1 parent bbe09e5 commit bdc3c3e

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

src/components/Dialog/FormDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export const FormDialog = <
139139
<button
140140
className='str-chat__dialog__controls-button str-chat__dialog__controls-button--cancel'
141141
onClick={close}
142+
type='button'
142143
>
143144
{t('Cancel')}
144145
</button>

src/components/MessageInput/EditMessageForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const EditMessageForm = () => {
5858
className='str-chat__edit-message-cancel'
5959
data-testid='cancel-button'
6060
onClick={cancel}
61+
type='button'
6162
>
6263
{t('Cancel')}
6364
</button>

src/components/MessageInput/__tests__/ThreadMessageInput.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ describe('MessageInput in Thread', () => {
172172
customClient,
173173
});
174174
expect(getDraftSpy).toHaveBeenCalledTimes(1);
175+
await act(() => {
176+
customClient.setMessageComposerSetupFunction(({ composer }) => {
177+
composer.updateConfig({ drafts: { enabled: false } });
178+
});
179+
});
175180
});
176181
it('prevents querying if composition is not empty', async () => {
177182
const { customChannel, customClient, getDraftSpy } = await setup();
@@ -186,6 +191,11 @@ describe('MessageInput in Thread', () => {
186191
customClient,
187192
});
188193
expect(getDraftSpy).not.toHaveBeenCalled();
194+
await act(() => {
195+
customClient.setMessageComposerSetupFunction(({ composer }) => {
196+
composer.updateConfig({ drafts: { enabled: false } });
197+
});
198+
});
189199
});
190200
it('prevents querying if not rendered inside a thread', async () => {
191201
const { customChannel, customClient, getDraftSpy } = await setup();
@@ -200,6 +210,11 @@ describe('MessageInput in Thread', () => {
200210
customClient,
201211
});
202212
expect(getDraftSpy).not.toHaveBeenCalled();
213+
await act(() => {
214+
customClient.setMessageComposerSetupFunction(({ composer }) => {
215+
composer.updateConfig({ drafts: { enabled: false } });
216+
});
217+
});
203218
});
204219
it('prevents querying if drafts are disabled (default)', async () => {
205220
const { customChannel, customClient, getDraftSpy } = await setup();

src/components/Poll/PollCreationDialog/OptionFieldSet.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export const OptionFieldSet = () => {
6565
});
6666
}}
6767
onKeyUp={(event) => {
68-
if (event.key === 'Enter') {
68+
const isFocusedLastOptionField = i === options.length - 1;
69+
if (event.key === 'Enter' && !isFocusedLastOptionField) {
6970
const nextInputId = options[i + 1].id;
7071
document.getElementById(nextInputId)?.focus();
7172
}

src/components/Poll/PollCreationDialog/PollCreationDialogControls.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const PollCreationDialogControls = ({
2222
messageComposer.pollComposer.initState();
2323
close();
2424
}}
25+
type='button'
2526
>
2627
{t('Cancel')}
2728
</button>

0 commit comments

Comments
 (0)