mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
web/composer: close emoji picker after selecting
This commit is contained in:
parent
79349cffc1
commit
60a2e52a0c
1 changed files with 14 additions and 5 deletions
|
@ -459,11 +459,20 @@ const MessageComposer = () => {
|
|||
content: <EmojiPicker
|
||||
style={getEmojiPickerStyle()}
|
||||
room={roomCtx.store}
|
||||
onSelect={(emoji: PartialEmoji) => setState({
|
||||
onSelect={(emoji: PartialEmoji) => {
|
||||
const mdEmoji = emojiToMarkdown(emoji)
|
||||
setState({
|
||||
text: state.text.slice(0, textInput.current?.selectionStart ?? 0)
|
||||
+ emojiToMarkdown(emoji)
|
||||
+ mdEmoji
|
||||
+ 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(),
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue