Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: also detect ime composing on sql ai command

Greg Richardson81046ad47eba
diff --git a/packages/ui/src/components/Command/AiCommand.tsx b/packages/ui/src/components/Command/AiCommand.tsx
index 1ddebd20256..48a35a8c788 100644
--- a/packages/ui/src/components/Command/AiCommand.tsx
+++ b/packages/ui/src/components/Command/AiCommand.tsx
@@ -383,7 +383,7 @@ const AiCommand = () => {
}, [])
// Detect an IME composition (so that we can ignore Enter keypress)
- const [isComposing, setIsComposing] = useState(false)
+ const [isImeComposing, setIsImeComposing] = useState(false)
return (
<div onClick={(e) => e.stopPropagation()}>
@@ -509,19 +509,15 @@ const AiCommand = () => {
setSearch(e.target.value)
}
}}
- onCompositionStart={() => setIsComposing(true)}
- onCompositionEnd={() => setIsComposing(false)}
+ onCompositionStart={() => setIsImeComposing(true)}
+ onCompositionEnd={() => setIsImeComposing(false)}
onKeyDown={(e) => {
switch (e.key) {
case 'Enter':
- if (!search) {
+ if (!search || isLoading || isResponding || isImeComposing) {
return
}
- if (isLoading || isResponding || isComposing) {
- return
- }
- handleSubmit(search)
- return
+ return handleSubmit(search)
default:
return
}
diff --git a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx
index 9a29d8bb6e8..f25aec4fcbb 100644
--- a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx
+++ b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx
@@ -74,6 +74,9 @@ const GenerateSQL = () => {
if (search) handleSubmit(search)
}, [])
+ // Detect an IME composition (so that we can ignore Enter keypress)
+ const [isImeComposing, setIsImeComposing] = useState(false)
+
const formatAnswer = (answer: string) => {
try {
return format(answer, {
@@ -210,7 +213,9 @@ const GenerateSQL = () => {
onKeyDown={(e) => {
switch (e.key) {
case 'Enter':
- if (!search || isLoading || isResponding) return
+ if (!search || isLoading || isResponding || isImeComposing) {
+ return
+ }
return handleSubmit(query)
default:
return
@@ -311,10 +316,14 @@ const GenerateSQL = () => {
setSearch(e.target.value)
}
}}
+ onCompositionStart={() => setIsImeComposing(true)}
+ onCompositionEnd={() => setIsImeComposing(false)}
onKeyDown={(e) => {
switch (e.key) {
case 'Enter':
- if (!search || isLoading || isResponding) return
+ if (!search || isLoading || isResponding || isImeComposing) {
+ return
+ }
return handleSubmit(search)
default:
return