Fix Japanese input when sending a chat message (#9206)

GitOrigin-RevId: a1b65129e94735f0215ff2eaa9a8a36dd6093176
This commit is contained in:
Alf Eaton 2022-08-11 10:16:24 +01:00 committed by Copybot
parent 19db9c2583
commit e103f736e1

View file

@ -8,12 +8,18 @@ function MessageInput({ resetUnreadMessages, sendMessage }) {
if (event.key === 'Enter') {
event.preventDefault()
sendMessage(event.target.value)
event.target.value = '' // clears the textarea content
// wrap the form reset in setTimeout so input sources have time to finish
// https://github.com/overleaf/internal/pull/9206
window.setTimeout(() => {
event.target.blur()
event.target.closest('form').reset()
event.target.focus()
}, 0)
}
}
return (
<div className="new-message">
<form className="new-message">
<label htmlFor="chat-input" className="sr-only">
{t('your_message')}
</label>
@ -23,7 +29,7 @@ function MessageInput({ resetUnreadMessages, sendMessage }) {
onKeyDown={handleKeyDown}
onClick={resetUnreadMessages}
/>
</div>
</form>
)
}