Mooeypoo has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/346484 )

Change subject: MenuSelectWidget: Highlight the first result when searching
......................................................................

MenuSelectWidget: Highlight the first result when searching

When we search for an item, highlight the first result found.
This is similar to what happens when we move with the arrow keys
and makes sense for highlighting the first search. It also gives
the option to the user of this widget to call on
this.getHighligtedItem() to pick the first result of the search.
Similar also to an autocomplete feature.

Change-Id: I66339c2efaf9b7b9a3ea88d59ad087ae102dbbad
---
M src/widgets/MenuSelectWidget.js
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/84/346484/1

diff --git a/src/widgets/MenuSelectWidget.js b/src/widgets/MenuSelectWidget.js
index e71f34b..15dbd57 100644
--- a/src/widgets/MenuSelectWidget.js
+++ b/src/widgets/MenuSelectWidget.js
@@ -134,6 +134,7 @@
  */
 OO.ui.MenuSelectWidget.prototype.updateItemVisibility = function () {
        var i, item, visible, section, sectionEmpty,
+               firstItemFound = false,
                anyVisible = false,
                len = this.items.length,
                showAll = !this.isVisible(),
@@ -155,6 +156,11 @@
                        anyVisible = anyVisible || visible;
                        sectionEmpty = sectionEmpty && !visible;
                        item.toggle( visible );
+                       if ( visible && !firstItemFound ) {
+                               // Highlight the first item in the list
+                               this.highlightItem( item );
+                               firstItemFound = true;
+                       }
                }
        }
        // Process the final section

-- 
To view, visit https://gerrit.wikimedia.org/r/346484
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I66339c2efaf9b7b9a3ea88d59ad087ae102dbbad
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to