on main help sign in
fix(tui): prevent dialog keymaps from being swallowed (#782)

This change checks for the presence of a dialog before checking for other handlers. Now when pressing ctrl+p when a dialog is visible it will correctly navigate up the list. This restores the standard terminal behavior of using ctrl+n and ctrl+p. How to reproduce: 1. ctrl+p to open for the command launcher 2. ctrl+n (or down) to move down one item 3. ctrl+p - command dialog closed With this fix, step 3. will now correctly select the previous item in the dialog.

commit63e53f1bc91482a8230954336c36fe79cba06b8b authorUri Gorelik <uri.gore@gmail.com> dateFri 15 Aug 2025, 16:51 (1 year ago) parent6c8b65a
1 file changed+12−13
internal/tui/tui.go+12−13
internal/tui/tui.go+12−13
@@ -372,6 +372,11 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
372372 return cmd
373373 }
374374 }
375+ if a.dialog.HasDialogs() {
376+ u, dialogCmd := a.dialog.Update(msg)
377+ a.dialog = u.(dialogs.DialogCmp)
378+ return dialogCmd
379+ }
375380 switch {
376381 // help
377382 case key.Matches(msg, a.keyMap.Help):
@@ -432,20 +437,14 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
432437 }
433438 return tea.Suspend
434439 default:
435− if a.dialog.HasDialogs() {
436− u, dialogCmd := a.dialog.Update(msg)
437− a.dialog = u.(dialogs.DialogCmp)
438− return dialogCmd
439− } else {
440− item, ok := a.pages[a.currentPage]
441− if !ok {
442− return nil
443− }
444−
445− updated, cmd := item.Update(msg)
446− a.pages[a.currentPage] = updated.(util.Model)
447− return cmd
440+ item, ok := a.pages[a.currentPage]
441+ if !ok {
442+ return nil
448443 }
444+
445+ updated, cmd := item.Update(msg)
446+ a.pages[a.currentPage] = updated.(util.Model)
447+ return cmd
449448 }
450449}
451450