do not highlight line if there are no items to display
This commit is contained in:
@@ -37,6 +37,8 @@ func formatListFooter(selectedLineIdx int, length int) string {
|
||||
func (self *ListContextTrait) HandleFocus(opts ...types.OnFocusOpts) error {
|
||||
self.FocusLine()
|
||||
|
||||
self.viewTrait.SetHighlight(self.list.Len() > 0)
|
||||
|
||||
return self.Context.HandleFocus(opts...)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,12 @@ func (self *ListCursor) GetSelectedLineIdx() int {
|
||||
}
|
||||
|
||||
func (self *ListCursor) SetSelectedLineIdx(value int) {
|
||||
self.selectedIdx = utils.Clamp(value, 0, self.list.Len()-1)
|
||||
clampedValue := -1
|
||||
if self.list.Len() > 0 {
|
||||
clampedValue = utils.Clamp(value, 0, self.list.Len()-1)
|
||||
}
|
||||
|
||||
self.selectedIdx = clampedValue
|
||||
}
|
||||
|
||||
// moves the cursor up or down by the given amount
|
||||
|
||||
@@ -31,6 +31,10 @@ func (self *ViewTrait) SetContent(content string) {
|
||||
self.view.SetContent(content)
|
||||
}
|
||||
|
||||
func (self *ViewTrait) SetHighlight(highlight bool) {
|
||||
self.view.Highlight = highlight
|
||||
}
|
||||
|
||||
func (self *ViewTrait) SetFooter(value string) {
|
||||
self.view.Footer = value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user