6dbdb434ea93d66b8dfacac8e615263c159356d1

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(ui): quitting on filtering

Diff

 1diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go
 2index 6ac4bf7869283d5fd59079adff93f2e6fb0f573d..52cd06cc56cd97be2d03ecc4dee07cb21e839fbe 100644
 3--- a/ui/pages/selection/selection.go
 4+++ b/ui/pages/selection/selection.go
 5@@ -5,6 +5,7 @@ import (
 6 	"strings"
 7 
 8 	"github.com/charmbracelet/bubbles/key"
 9+	"github.com/charmbracelet/bubbles/list"
10 	tea "github.com/charmbracelet/bubbletea"
11 	"github.com/charmbracelet/lipgloss"
12 	"github.com/charmbracelet/soft-serve/config"
13@@ -88,6 +89,11 @@ func (s *Selection) getMargins() (wm, hm int) {
14 	return
15 }
16 
17+// FilterState returns the current filter state.
18+func (s *Selection) FilterState() list.FilterState {
19+	return s.selector.FilterState()
20+}
21+
22 // SetSize implements common.Component.
23 func (s *Selection) SetSize(width, height int) {
24 	s.common.SetSize(width, height)
25diff --git a/ui/ui.go b/ui/ui.go
26index 1eb1e0d4356902042e20125a86b35892ae3ae8ac..3f18e577e55bcc60ebc1ec45ea200c2bd93ed194 100644
27--- a/ui/ui.go
28+++ b/ui/ui.go
29@@ -2,6 +2,7 @@ package ui
30 
31 import (
32 	"github.com/charmbracelet/bubbles/key"
33+	"github.com/charmbracelet/bubbles/list"
34 	tea "github.com/charmbracelet/bubbletea"
35 	"github.com/charmbracelet/lipgloss"
36 	"github.com/charmbracelet/soft-serve/config"
37@@ -180,9 +181,17 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
38 			case key.Matches(msg, ui.common.KeyMap.Help):
39 				cmds = append(cmds, footer.ToggleFooterCmd)
40 			case key.Matches(msg, ui.common.KeyMap.Quit):
41-				// Stop bubblezone background workers.
42-				ui.common.Zone.Close()
43-				return ui, tea.Quit
44+				switch {
45+				case ui.activePage == selectionPage:
46+					if s, ok := ui.pages[selectionPage].(*selection.Selection); ok && s.FilterState() == list.Filtering {
47+						break
48+					}
49+					fallthrough
50+				default:
51+					// Stop bubblezone background workers.
52+					ui.common.Zone.Close()
53+					return ui, tea.Quit
54+				}
55 			case ui.activePage == repoPage && key.Matches(msg, ui.common.KeyMap.Back):
56 				ui.activePage = selectionPage
57 				// Always show the footer on selection page.