fix(app): keep Escape handling local to prompt input on macOS desktop (#13963)
This commit is contained in:
@@ -280,6 +280,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isFocused = createFocusSignal(() => editorRef)
|
const isFocused = createFocusSignal(() => editorRef)
|
||||||
|
const escBlur = () => platform.platform === "desktop" && platform.os === "macos"
|
||||||
|
|
||||||
const closePopover = () => setStore("popover", null)
|
const closePopover = () => setStore("popover", null)
|
||||||
|
|
||||||
@@ -842,13 +843,39 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (store.mode === "shell") {
|
|
||||||
const { collapsed, cursorPosition, textLength } = getCaretState()
|
if (event.key === "Escape") {
|
||||||
if (event.key === "Escape") {
|
if (store.popover) {
|
||||||
setStore("mode", "normal")
|
closePopover()
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (store.mode === "shell") {
|
||||||
|
setStore("mode", "normal")
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (working()) {
|
||||||
|
abort()
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (escBlur()) {
|
||||||
|
editorRef.blur()
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (store.mode === "shell") {
|
||||||
|
const { collapsed, cursorPosition, textLength } = getCaretState()
|
||||||
if (event.key === "Backspace" && collapsed && cursorPosition === 0 && textLength === 0) {
|
if (event.key === "Backspace" && collapsed && cursorPosition === 0 && textLength === 0) {
|
||||||
setStore("mode", "normal")
|
setStore("mode", "normal")
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@@ -927,13 +954,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
if (event.key === "Enter" && !event.shiftKey) {
|
if (event.key === "Enter" && !event.shiftKey) {
|
||||||
handleSubmit(event)
|
handleSubmit(event)
|
||||||
}
|
}
|
||||||
if (event.key === "Escape") {
|
|
||||||
if (store.popover) {
|
|
||||||
closePopover()
|
|
||||||
} else if (working()) {
|
|
||||||
abort()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user