diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go index 6ac4bf7869283d5fd59079adff93f2e6fb0f573d..52cd06cc56cd97be2d03ecc4dee07cb21e839fbe 100644 --- a/ui/pages/selection/selection.go +++ b/ui/pages/selection/selection.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/charmbracelet/bubbles/key" + "github.com/charmbracelet/bubbles/list" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/soft-serve/config" @@ -88,6 +89,11 @@ func (s *Selection) getMargins() (wm, hm int) { return } +// FilterState returns the current filter state. +func (s *Selection) FilterState() list.FilterState { + return s.selector.FilterState() +} + // SetSize implements common.Component. func (s *Selection) SetSize(width, height int) { s.common.SetSize(width, height) diff --git a/ui/ui.go b/ui/ui.go index 1eb1e0d4356902042e20125a86b35892ae3ae8ac..3f18e577e55bcc60ebc1ec45ea200c2bd93ed194 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -2,6 +2,7 @@ package ui import ( "github.com/charmbracelet/bubbles/key" + "github.com/charmbracelet/bubbles/list" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/soft-serve/config" @@ -180,9 +181,17 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case key.Matches(msg, ui.common.KeyMap.Help): cmds = append(cmds, footer.ToggleFooterCmd) case key.Matches(msg, ui.common.KeyMap.Quit): - // Stop bubblezone background workers. - ui.common.Zone.Close() - return ui, tea.Quit + switch { + case ui.activePage == selectionPage: + if s, ok := ui.pages[selectionPage].(*selection.Selection); ok && s.FilterState() == list.Filtering { + break + } + fallthrough + default: + // Stop bubblezone background workers. + ui.common.Zone.Close() + return ui, tea.Quit + } case ui.activePage == repoPage && key.Matches(msg, ui.common.KeyMap.Back): ui.activePage = selectionPage // Always show the footer on selection page.