Skip to content

Commit

Permalink
fix(ui): bad page when using return key on error (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
eremid authored Jun 7, 2023
1 parent cf61f07 commit 09635fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
13 changes: 7 additions & 6 deletions tui/pages/common/back.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
func (m *Model) Back() (*Model, []tea.Cmd) {
var cmds []tea.Cmd

m.ClearContextToStop()

m.RestorePreviousKeys()
cmdView := m.RestorePreviousView()

cmds = append(cmds, cmdView)
if len(m.contextToStop) > 0 {
m.ClearContextToStop()
} else {
m.RestorePreviousKeys()
cmdView := m.RestorePreviousView()
cmds = append(cmds, cmdView)
}

return m, cmds
}
10 changes: 6 additions & 4 deletions tui/pages/common/pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func BeanPages() map[PageID]*Page {

errorP := &Page{
Keys: errorKeys,
previousPage: PRoot,
previousPage: PActual,
}

pages[PRoot] = root
Expand All @@ -98,11 +98,13 @@ func BeanPages() map[PageID]*Page {

// RestorePreviousKeys restore the keys.
func (m *Model) RestorePreviousKeys() tea.Cmd {
*m.keys = *m.pages[PRoot].Keys

if _, ok := m.pages[m.viewName]; ok {
previousPage := m.pages[m.viewName].previousPage
*m.keys = *m.pages[previousPage].Keys
} else {
*m.keys = *m.pages[PRoot].Keys
if m.pages[previousPage].Keys != nil {
*m.keys = *m.pages[previousPage].Keys
}
}
return nil
}
Expand Down

0 comments on commit 09635fe

Please sign in to comment.