17bf5843492860d1d31b41f90b228534f9f59292

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

Message

fix(ui): hide tabs while filtering

Fixes: https://github.com/charmbracelet/soft-serve/issues/172

Diff

 1diff --git a/ui/pages/repo/repo.go b/ui/pages/repo/repo.go
 2index 6469fe6d4f79043a1f4298444195f93634e2d237..808ae9286cc35b71d96771a1074f32455d3e8ee3 100644
 3--- a/ui/pages/repo/repo.go
 4+++ b/ui/pages/repo/repo.go
 5@@ -111,9 +111,7 @@ func (r *Repo) SetSize(width, height int) {
 6 	hm := r.common.Styles.Repo.Body.GetVerticalFrameSize() +
 7 		r.common.Styles.Repo.Header.GetHeight() +
 8 		r.common.Styles.Repo.Header.GetVerticalFrameSize() +
 9-		r.common.Styles.StatusBar.GetHeight() +
10-		r.common.Styles.Tabs.GetHeight() +
11-		r.common.Styles.Tabs.GetVerticalFrameSize()
12+		r.common.Styles.StatusBar.GetHeight()
13 	r.tabs.SetSize(width, height-hm)
14 	r.statusbar.SetSize(width, height-hm)
15 	for _, p := range r.panes {
16diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go
17index 52cd06cc56cd97be2d03ecc4dee07cb21e839fbe..c0957fcdd9c3dff3519e2587a476903170731515 100644
18--- a/ui/pages/selection/selection.go
19+++ b/ui/pages/selection/selection.go
20@@ -81,10 +81,10 @@ func New(cfg *config.Config, pk ssh.PublicKey, common common.Common) *Selection
21 func (s *Selection) getMargins() (wm, hm int) {
22 	wm = 0
23 	hm = s.common.Styles.Tabs.GetVerticalFrameSize() +
24-		s.common.Styles.Tabs.GetHeight() +
25-		2 // tabs margin see View()
26-	if s.activePane == readmePane {
27-		hm += 1 // readme statusbar
28+		s.common.Styles.Tabs.GetHeight()
29+	if s.activePane == selectorPane && s.FilterState() == list.Filtering {
30+		// hide tabs when filtering
31+		hm = 0
32 	}
33 	return
34 }
35@@ -100,7 +100,7 @@ func (s *Selection) SetSize(width, height int) {
36 	wm, hm := s.getMargins()
37 	s.tabs.SetSize(width, height-hm)
38 	s.selector.SetSize(width-wm, height-hm)
39-	s.readme.SetSize(width-wm, height-hm)
40+	s.readme.SetSize(width-wm, height-hm-1) // -1 for readme status line
41 }
42 
43 // ShortHelp implements help.KeyMap.
44@@ -287,7 +287,6 @@ func (s *Selection) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
45 func (s *Selection) View() string {
46 	var view string
47 	wm, hm := s.getMargins()
48-	hm++ // tabs margin
49 	switch s.activePane {
50 	case selectorPane:
51 		ss := lipgloss.NewStyle().
52@@ -308,9 +307,15 @@ func (s *Selection) View() string {
53 			readmeStatus,
54 		))
55 	}
56+	if s.activePane != selectorPane || s.FilterState() != list.Filtering {
57+		tabs := s.common.Styles.Tabs.Render(s.tabs.View())
58+		view = lipgloss.JoinVertical(lipgloss.Left,
59+			tabs,
60+			view,
61+		)
62+	}
63 	return lipgloss.JoinVertical(
64 		lipgloss.Left,
65-		s.common.Styles.Tabs.Render(s.tabs.View()),
66 		view,
67 	)
68 }
69diff --git a/ui/styles/styles.go b/ui/styles/styles.go
70index a55a28f2d434c5cd489b7af8c09e2d030d5f808c..4e1c14440bc09e0e45cfd63e70c07c40a61ef4f9 100644
71--- a/ui/styles/styles.go
72+++ b/ui/styles/styles.go
73@@ -439,7 +439,8 @@ func DefaultStyles() *Styles {
74 		Background(lipgloss.Color("237")).
75 		Foreground(lipgloss.Color("243"))
76 
77-	s.Tabs = lipgloss.NewStyle()
78+	s.Tabs = lipgloss.NewStyle().
79+		Height(1)
80 
81 	s.TabInactive = lipgloss.NewStyle()
82