@@ -85,18 +85,15 @@ func (f *ModelsList) SetSelected(index int) {
85// SetSelectedItem sets the selected item in the list by item ID.
85// SetSelectedItem sets the selected item in the list by item ID.
86func (f *ModelsList) SetSelectedItem(itemID string) {
86func (f *ModelsList) SetSelectedItem(itemID string) {
87 if itemID == "" {
87 if itemID == "" {
92− count := 0
91+ // Walk the selectable model items using the same helpers that
93− for _, g := range f.groups {
92+ // keyboard navigation uses, so we stay in sync with the flat
94− for _, item := range g.Items {
93+ // list layout.
95− if item.ID() == itemID {
94+ for ok := f.SelectFirst(); ok; ok = f.SelectNext() {
96− f.SetSelected(count)
95+ if mi, is := f.SelectedItem().(*ModelItem); is && mi.ID() == itemID {