mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-23 10:44:21 +01:00
fix(tui): Allow modals to handle ESC key before force closing (#3279)
This commit is contained in:
@@ -162,9 +162,15 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
// 1. Handle active modal
|
// 1. Handle active modal
|
||||||
if a.modal != nil {
|
if a.modal != nil {
|
||||||
switch keyString {
|
switch keyString {
|
||||||
// Escape always closes current modal
|
// Escape closes current modal, but give modal a chance to handle it first
|
||||||
case "esc":
|
case "esc":
|
||||||
cmd := a.modal.Close()
|
// give the modal a chance to handle the esc
|
||||||
|
updatedModal, cmd := a.modal.Update(msg)
|
||||||
|
a.modal = updatedModal.(layout.Modal)
|
||||||
|
if cmd != nil {
|
||||||
|
return a, cmd
|
||||||
|
}
|
||||||
|
cmd = a.modal.Close()
|
||||||
a.modal = nil
|
a.modal = nil
|
||||||
return a, cmd
|
return a, cmd
|
||||||
case "ctrl+c":
|
case "ctrl+c":
|
||||||
|
|||||||
Reference in New Issue
Block a user