mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-25 06:31:52 +00:00
Merge pull request #14673 from overleaf/jdt-improve-character-selection-chat
Jdt improve character selection chat GitOrigin-RevId: 9d9f22aeda5e333e807b710f8ea14bbd47dc7f0c
This commit is contained in:
parent
d19090e398
commit
7a7689e9c5
1 changed files with 14 additions and 7 deletions
|
@ -1,19 +1,26 @@
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
function MessageInput({ resetUnreadMessages, sendMessage }) {
|
type MessageInputProps = {
|
||||||
|
resetUnreadMessages: () => void
|
||||||
|
sendMessage: (message: string) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
function MessageInput({ resetUnreadMessages, sendMessage }: MessageInputProps) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
function handleKeyDown(event) {
|
function handleKeyDown(event: React.KeyboardEvent) {
|
||||||
if (event.key === 'Enter') {
|
const selectingCharacter = event.nativeEvent.isComposing
|
||||||
|
if (event.key === 'Enter' && !selectingCharacter) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
sendMessage(event.target.value)
|
const target = event.target as HTMLInputElement
|
||||||
|
sendMessage(target.value)
|
||||||
// wrap the form reset in setTimeout so input sources have time to finish
|
// wrap the form reset in setTimeout so input sources have time to finish
|
||||||
// https://github.com/overleaf/internal/pull/9206
|
// https://github.com/overleaf/internal/pull/9206
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
event.target.blur()
|
target.blur()
|
||||||
event.target.closest('form').reset()
|
target.closest('form')?.reset()
|
||||||
event.target.focus()
|
target.focus()
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue