@@ -31,9 +31,6 @@ type List struct {
31 // scrolled out of view (above the viewport).
31 // scrolled out of view (above the viewport).
32 // It must always be >= 0.
32 // It must always be >= 0.
33 offsetLine int
33 offsetLine int
36− dirtyItems map[int]struct{}
39// renderedItem holds the rendered content and height of an item.
36// renderedItem holds the rendered content and height of an item.
@@ -47,7 +44,6 @@ func NewList(items ...Item) *List {
47 l := new(List)
44 l := new(List)
48 l.items = items
45 l.items = items
49 l.renderedItems = make(map[int]renderedItem)
46 l.renderedItems = make(map[int]renderedItem)
50− l.dirtyItems = make(map[int]struct{})
@@ -88,9 +84,7 @@ func (l *List) getItem(idx int) renderedItem {
90 if item, ok := l.renderedItems[idx]; ok {
86 if item, ok := l.renderedItems[idx]; ok {
91− if _, dirty := l.dirtyItems[idx]; !dirty {
92− return item
87+ return item
96 item := l.items[idx]
90 item := l.items[idx]
@@ -104,7 +98,6 @@ func (l *List) getItem(idx int) renderedItem {
106 l.renderedItems[idx] = ri
100 l.renderedItems[idx] = ri
107− delete(l.dirtyItems, idx)
109 return ri
102 return ri
@@ -301,13 +294,6 @@ func (l *List) PrependItems(items ...Item) {
302 l.renderedItems = newCache
295 l.renderedItems = newCache
304− // Shift dirty items
305− newDirty := make(map[int]struct{})
306− for idx := range l.dirtyItems {
307− newDirty[idx+len(items)] = struct{}{}
309− l.dirtyItems = newDirty
311 // Keep view position relative to the content that was visible
297 // Keep view position relative to the content that was visible
312 l.offsetIdx += len(items)
298 l.offsetIdx += len(items)
@@ -325,6 +311,9 @@ func (l *List) AppendItems(items ...Item) {
325// Focus sets the focus state of the list.
311// Focus sets the focus state of the list.
326func (l *List) Focus() {
312func (l *List) Focus() {
327 l.focused = true
313 l.focused = true
314+ if l.selectedIdx < 0 || l.selectedIdx > len(l.items)-1 {
330// Blur removes the focus state from the list.
319// Blur removes the focus state from the list.