1
0
Fork 0
forked from Mirrors/gomuks

web/composer: close emoji picker after selecting

This commit is contained in:
Tulir Asokan 2024-12-19 23:19:04 +02:00
parent 79349cffc1
commit 60a2e52a0c

View file

@ -459,11 +459,20 @@ const MessageComposer = () => {
content: <EmojiPicker content: <EmojiPicker
style={getEmojiPickerStyle()} style={getEmojiPickerStyle()}
room={roomCtx.store} room={roomCtx.store}
onSelect={(emoji: PartialEmoji) => setState({ onSelect={(emoji: PartialEmoji) => {
const mdEmoji = emojiToMarkdown(emoji)
setState({
text: state.text.slice(0, textInput.current?.selectionStart ?? 0) text: state.text.slice(0, textInput.current?.selectionStart ?? 0)
+ emojiToMarkdown(emoji) + mdEmoji
+ state.text.slice(textInput.current?.selectionEnd ?? 0), + state.text.slice(textInput.current?.selectionEnd ?? 0),
})} })
if (textInput.current) {
textInput.current.setSelectionRange(textInput.current.selectionStart + mdEmoji.length, 0)
}
}}
// TODO allow keeping open on select on non-mobile devices
// (requires onSelect to be able to keep track of the state after updating it)
closeOnSelect={true}
/>, />,
onClose: () => !isMobileDevice && textInput.current?.focus(), onClose: () => !isMobileDevice && textInput.current?.focus(),
}) })