Skip to content

Commit

Permalink
regression: Messagebox sending message instead of just selecting popu…
Browse files Browse the repository at this point in the history
…p suggestion (#32890)
  • Loading branch information
gabriellsh authored and ggazzo committed Jul 26, 2024
1 parent fb9c3e9 commit d26eb5b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const useComposerBoxPopup = <T extends { _id: string; sort?: number }>({
setPopup(undefined);
setFocused(undefined);
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
}
});

Expand All @@ -192,7 +192,7 @@ export const useComposerBoxPopup = <T extends { _id: string; sort?: number }>({
select(focused);

event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
return true;
}
if (event.which === keys.ARROW_UP && !(event.shiftKey || event.ctrlKey || event.altKey || event.metaKey)) {
Expand All @@ -211,7 +211,7 @@ export const useComposerBoxPopup = <T extends { _id: string; sort?: number }>({
return (focusedIndex > 0 ? list[focusedIndex - 1] : list[list.length - 1]) as T;
});
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
return true;
}
if (event.which === keys.ARROW_DOWN && !(event.shiftKey || event.ctrlKey || event.altKey || event.metaKey)) {
Expand All @@ -230,7 +230,7 @@ export const useComposerBoxPopup = <T extends { _id: string; sort?: number }>({
return (focusedIndex < list.length - 1 ? list[focusedIndex + 1] : list[0]) as T;
});
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
return true;
}
});
Expand Down
35 changes: 35 additions & 0 deletions apps/meteor/tests/e2e/message-composer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,39 @@ test.describe.serial('message-composer', () => {

await expect(poHomeChannel.composer).toHaveValue(`[hello composer](${url})`);
});

test('should select popup item and not send the message when pressing enter', async ({ page }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.sendMessage('hello composer');

await test.step('mention popup', async () => {
await page.keyboard.type('hello composer @all');

await page.keyboard.press('Enter');

await expect(poHomeChannel.composer).toHaveValue('hello composer @all ');

await poHomeChannel.composer.fill('');
});

await test.step('emoji popup', async () => {
await page.keyboard.type('hello composer :flag_br');

await page.keyboard.press('Enter');

await expect(poHomeChannel.composer).toHaveValue('hello composer :flag_br: ');

await poHomeChannel.composer.fill('');
});

await test.step('slash command', async () => {
await page.keyboard.type('/gim');

await page.keyboard.press('Enter');

await expect(poHomeChannel.composer).toHaveValue('/gimme ');

await poHomeChannel.composer.fill('');
});
});
});

0 comments on commit d26eb5b

Please sign in to comment.