Skip to content

Commit 0186a85

Browse files
authored
fix(app): keep Escape handling local to prompt input on macOS desktop (#13963)
1 parent ed4e484 commit 0186a85

1 file changed

Lines changed: 30 additions & 10 deletions

File tree

packages/app/src/components/prompt-input.tsx

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
280280
}
281281

282282
const isFocused = createFocusSignal(() => editorRef)
283+
const escBlur = () => platform.platform === "desktop" && platform.os === "macos"
283284

284285
const closePopover = () => setStore("popover", null)
285286

@@ -842,13 +843,39 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
842843
return
843844
}
844845
}
845-
if (store.mode === "shell") {
846-
const { collapsed, cursorPosition, textLength } = getCaretState()
847-
if (event.key === "Escape") {
846+
847+
if (event.key === "Escape") {
848+
if (store.popover) {
849+
closePopover()
850+
event.preventDefault()
851+
event.stopPropagation()
852+
return
853+
}
854+
855+
if (store.mode === "shell") {
848856
setStore("mode", "normal")
849857
event.preventDefault()
858+
event.stopPropagation()
859+
return
860+
}
861+
862+
if (working()) {
863+
abort()
864+
event.preventDefault()
865+
event.stopPropagation()
866+
return
867+
}
868+
869+
if (escBlur()) {
870+
editorRef.blur()
871+
event.preventDefault()
872+
event.stopPropagation()
850873
return
851874
}
875+
}
876+
877+
if (store.mode === "shell") {
878+
const { collapsed, cursorPosition, textLength } = getCaretState()
852879
if (event.key === "Backspace" && collapsed && cursorPosition === 0 && textLength === 0) {
853880
setStore("mode", "normal")
854881
event.preventDefault()
@@ -927,13 +954,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
927954
if (event.key === "Enter" && !event.shiftKey) {
928955
handleSubmit(event)
929956
}
930-
if (event.key === "Escape") {
931-
if (store.popover) {
932-
closePopover()
933-
} else if (working()) {
934-
abort()
935-
}
936-
}
937957
}
938958

939959
return (

0 commit comments

Comments
 (0)