EmojiPicker: Don't send on enter, just add emoji to draft message

This commit is contained in:
Scott Nonnenberg 2023-11-21 11:15:39 -08:00 committed by GitHub
parent 3c12a0aad0
commit 7a182636d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 12 deletions

View file

@ -543,7 +543,6 @@ export function CompositionArea({
<EmojiButton
emojiButtonApi={emojiButtonRef}
i18n={i18n}
doSend={handleForceSend}
onPickEmoji={insertEmoji}
onClose={() => setComposerFocus(conversationId)}
recentEmojis={recentEmojis}

View file

@ -33,7 +33,7 @@ export type OwnProps = Readonly<{
export type Props = OwnProps &
Pick<
EmojiPickerProps,
'doSend' | 'onPickEmoji' | 'onSetSkinTone' | 'recentEmojis' | 'skinTone'
'onPickEmoji' | 'onSetSkinTone' | 'recentEmojis' | 'skinTone'
>;
export type EmojiButtonAPI = Readonly<{
@ -46,7 +46,6 @@ export const EmojiButton = React.memo(function EmojiButtonInner({
emoji,
emojiButtonApi,
i18n,
doSend,
onClose,
onOpen,
onPickEmoji,
@ -178,7 +177,6 @@ export const EmojiButton = React.memo(function EmojiButtonInner({
handleClose();
}
}}
doSend={doSend}
onClose={handleClose}
skinTone={skinTone}
onSetSkinTone={onSetSkinTone}

View file

@ -34,7 +34,6 @@ export type EmojiPickDataType = {
export type OwnProps = {
readonly i18n: LocalizerType;
readonly onPickEmoji: (o: EmojiPickDataType) => unknown;
readonly doSend?: () => unknown;
readonly skinTone?: number;
readonly onSetSkinTone?: (tone: number) => unknown;
readonly recentEmojis?: ReadonlyArray<string>;
@ -71,7 +70,6 @@ export const EmojiPicker = React.memo(
(
{
i18n,
doSend,
onPickEmoji,
skinTone = 0,
onSetSkinTone,
@ -153,11 +151,7 @@ export const EmojiPicker = React.memo(
const { shortName } = e.currentTarget.dataset;
if ('key' in e) {
if (e.key === 'Enter') {
if (doSend) {
doSend();
e.stopPropagation();
e.preventDefault();
} else if (shortName) {
if (shortName) {
onPickEmoji({ skinTone: selectedTone, shortName });
e.stopPropagation();
e.preventDefault();
@ -169,7 +163,7 @@ export const EmojiPicker = React.memo(
onPickEmoji({ skinTone: selectedTone, shortName });
}
},
[doSend, onPickEmoji, selectedTone]
[onPickEmoji, selectedTone]
);
// Handle key presses, particularly Escape