File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -713,8 +713,6 @@ func (w *Widget[T]) removeItem(index int) {
713713}
714714
715715func (w * Widget [T ]) FocusFirst () {
716- w .focusManager .FocusFirst ()
717-
718716 if w .filterState == FilterApplied {
719717 if len (w .filteredListItems ) > 0 {
720718 w .globalIndex = w .filteredListItems [0 ].Index
@@ -729,6 +727,16 @@ func (w *Widget[T]) FocusFirst() {
729727 w .globalIndex = 0
730728 }
731729
730+ // Focus the cursor's global index directly. Filtering does not deactivate
731+ // the filtered-out items, so focusManager.FocusFirst would land on the
732+ // first item of the full list instead of the first filtered match, leaving
733+ // the focused style desynced from the cursor.
734+ if w .globalIndex >= 0 {
735+ w .focusManager .Focus (w .globalIndex )
736+ } else {
737+ w .focusManager .BlurCurrent ()
738+ }
739+
732740 w .moveCursor (w .globalIndex )
733741}
734742
You can’t perform that action at this time.
0 commit comments