Skip to content

Commit

Permalink
fix(ui): prevent submission while typing during isComposing state (#3006
Browse files Browse the repository at this point in the history
)
  • Loading branch information
liangfung authored Aug 28, 2024
1 parent bfb25e9 commit f2e586c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ee/tabby-ui/components/textarea-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ export default function TextAreaSearch({
getPreviouslySelectedRepo()
}, [])

const onSearchKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === 'Enter' && !e.shiftKey) return e.preventDefault()
}

const onSearchKeyUp = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === 'Enter' && !e.shiftKey) {
return search()
const onSearchKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (
event.key === 'Enter' &&
!event.shiftKey &&
!event.nativeEvent.isComposing
) {
event.preventDefault()
search()
}
}

Expand Down Expand Up @@ -172,7 +173,6 @@ export default function TextAreaSearch({
placeholder={placeholder || 'Ask anything...'}
maxRows={5}
onKeyDown={onSearchKeyDown}
onKeyUp={onSearchKeyUp}
onFocus={() => setIsFocus(true)}
onBlur={() => setIsFocus(false)}
onChange={e => setValue(e.target.value)}
Expand Down

0 comments on commit f2e586c

Please sign in to comment.