diff --git a/src/components/middle/composer/Composer.tsx b/src/components/middle/composer/Composer.tsx index 04a2afb0..b7f7a21d 100644 --- a/src/components/middle/composer/Composer.tsx +++ b/src/components/middle/composer/Composer.tsx @@ -538,7 +538,7 @@ const Composer: FC = ({ resetComposer, stopRecordingVoice, showDialog, slowMode, isAdmin, sendMessage, forwardMessages, lang, ]); - const handleStickerSelect = useCallback((sticker: ApiSticker) => { + const handleStickerSelect = useCallback((sticker: ApiSticker, shouldPreserveInput = false) => { sticker = { ...sticker, isPreloadedGlobally: true, @@ -549,7 +549,7 @@ const Composer: FC = ({ openCalendar(); } else { sendMessage({ sticker }); - requestAnimationFrame(() => { resetComposer(true); }); + requestAnimationFrame(() => { resetComposer(shouldPreserveInput); }); } }, [shouldSchedule, openCalendar, sendMessage, resetComposer]); diff --git a/src/components/middle/composer/EmojiTooltip.tsx b/src/components/middle/composer/EmojiTooltip.tsx index 6addb348..86656eab 100644 --- a/src/components/middle/composer/EmojiTooltip.tsx +++ b/src/components/middle/composer/EmojiTooltip.tsx @@ -105,6 +105,11 @@ const EmojiTooltip: FC = ({ } }, [addRecentEmoji, emojis, onEmojiSelect, selectedIndex]); + const handleClick = useCallback((native: string, id: string) => { + onEmojiSelect(native); + addRecentEmoji({ emoji: id }); + }, [addRecentEmoji, onEmojiSelect]); + useEffect(() => (isOpen ? captureKeyboardListeners({ onEsc: onClose, onLeft: (e: KeyboardEvent) => handleArrowKey(-1, e), @@ -138,7 +143,7 @@ const EmojiTooltip: FC = ({ key={emoji.id} emoji={emoji} focus={selectedIndex === index} - onClick={onEmojiSelect} + onClick={handleClick} /> )) ) : shouldRender ? ( diff --git a/src/components/middle/composer/SymbolMenu.tsx b/src/components/middle/composer/SymbolMenu.tsx index 40782c48..78a70e77 100644 --- a/src/components/middle/composer/SymbolMenu.tsx +++ b/src/components/middle/composer/SymbolMenu.tsx @@ -32,7 +32,7 @@ export type OwnProps = { onLoad: () => void; onClose: () => void; onEmojiSelect: (emoji: string) => void; - onStickerSelect: (sticker: ApiSticker) => void; + onStickerSelect: (sticker: ApiSticker, shouldPreserveInput?: boolean) => void; onGifSelect: (gif: ApiVideo) => void; onRemoveSymbol: () => void; onSearchOpen: (type: 'stickers' | 'gifs') => void; @@ -114,6 +114,10 @@ const SymbolMenu: FC = ({ onSearchOpen(type); }, [onClose, onSearchOpen]); + const handleStickerSelect = useCallback((sticker: ApiSticker) => { + onStickerSelect(sticker, true); + }, [onStickerSelect]); + const lang = useLang(); const { canSendStickers, canSendGifs } = allowedAttachmentOptions; @@ -133,7 +137,7 @@ const SymbolMenu: FC = ({ className="picker-tab" loadAndPlay={canSendStickers ? isOpen && (isActive || isFrom) : false} canSendStickers={canSendStickers} - onStickerSelect={onStickerSelect} + onStickerSelect={handleStickerSelect} /> ); case SymbolMenuTabs.GIFs: