fix(ui): hide tabs while filtering

Ayman Bagabas created

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

Change summary

ui/pages/repo/repo.go           |  4 +---
ui/pages/selection/selection.go | 19 ++++++++++++-------
ui/styles/styles.go             |  3 ++-
3 files changed, 15 insertions(+), 11 deletions(-)

Detailed changes

ui/pages/repo/repo.go 🔗

@@ -111,9 +111,7 @@ func (r *Repo) SetSize(width, height int) {
 	hm := r.common.Styles.Repo.Body.GetVerticalFrameSize() +
 		r.common.Styles.Repo.Header.GetHeight() +
 		r.common.Styles.Repo.Header.GetVerticalFrameSize() +
-		r.common.Styles.StatusBar.GetHeight() +
-		r.common.Styles.Tabs.GetHeight() +
-		r.common.Styles.Tabs.GetVerticalFrameSize()
+		r.common.Styles.StatusBar.GetHeight()
 	r.tabs.SetSize(width, height-hm)
 	r.statusbar.SetSize(width, height-hm)
 	for _, p := range r.panes {

ui/pages/selection/selection.go 🔗

@@ -81,10 +81,10 @@ func New(cfg *config.Config, pk ssh.PublicKey, common common.Common) *Selection
 func (s *Selection) getMargins() (wm, hm int) {
 	wm = 0
 	hm = s.common.Styles.Tabs.GetVerticalFrameSize() +
-		s.common.Styles.Tabs.GetHeight() +
-		2 // tabs margin see View()
-	if s.activePane == readmePane {
-		hm += 1 // readme statusbar
+		s.common.Styles.Tabs.GetHeight()
+	if s.activePane == selectorPane && s.FilterState() == list.Filtering {
+		// hide tabs when filtering
+		hm = 0
 	}
 	return
 }
@@ -100,7 +100,7 @@ func (s *Selection) SetSize(width, height int) {
 	wm, hm := s.getMargins()
 	s.tabs.SetSize(width, height-hm)
 	s.selector.SetSize(width-wm, height-hm)
-	s.readme.SetSize(width-wm, height-hm)
+	s.readme.SetSize(width-wm, height-hm-1) // -1 for readme status line
 }
 
 // ShortHelp implements help.KeyMap.
@@ -287,7 +287,6 @@ func (s *Selection) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 func (s *Selection) View() string {
 	var view string
 	wm, hm := s.getMargins()
-	hm++ // tabs margin
 	switch s.activePane {
 	case selectorPane:
 		ss := lipgloss.NewStyle().
@@ -308,9 +307,15 @@ func (s *Selection) View() string {
 			readmeStatus,
 		))
 	}
+	if s.activePane != selectorPane || s.FilterState() != list.Filtering {
+		tabs := s.common.Styles.Tabs.Render(s.tabs.View())
+		view = lipgloss.JoinVertical(lipgloss.Left,
+			tabs,
+			view,
+		)
+	}
 	return lipgloss.JoinVertical(
 		lipgloss.Left,
-		s.common.Styles.Tabs.Render(s.tabs.View()),
 		view,
 	)
 }

ui/styles/styles.go 🔗

@@ -439,7 +439,8 @@ func DefaultStyles() *Styles {
 		Background(lipgloss.Color("237")).
 		Foreground(lipgloss.Color("243"))
 
-	s.Tabs = lipgloss.NewStyle()
+	s.Tabs = lipgloss.NewStyle().
+		Height(1)
 
 	s.TabInactive = lipgloss.NewStyle()