mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Fix support for IME in Assistant prompt (#184874)
## Summary
Kudos to @sakurai-youhei for providing a fix 🙇
Tested on Chrome, Firefox, Safari
f0ff388f
-3943-4382-a873-88949b760629
---------
Co-authored-by: Garrett Spong <spong@users.noreply.github.com>
This commit is contained in:
parent
15345b6397
commit
87f0e71d19
1 changed files with 9 additions and 6 deletions
|
@ -29,13 +29,16 @@ export const PromptTextArea = forwardRef<HTMLTextAreaElement, Props>(
|
|||
|
||||
const onKeyDown = useCallback(
|
||||
(event) => {
|
||||
if (event.key === 'Enter' && !event.shiftKey && value.trim().length > 0) {
|
||||
// keyCode 13 is needed in case of IME input
|
||||
if (event.keyCode === 13 && !event.shiftKey) {
|
||||
event.preventDefault();
|
||||
onPromptSubmit(event.target.value?.trim());
|
||||
handlePromptChange('');
|
||||
} else if (event.key === 'Enter' && !event.shiftKey && value.trim().length === 0) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (value.trim().length) {
|
||||
onPromptSubmit(event.target.value?.trim());
|
||||
handlePromptChange('');
|
||||
} else {
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
},
|
||||
[value, onPromptSubmit, handlePromptChange]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue