Page MenuHomePhabricator

first item in namespace drop-down isn't always preselected
Closed, ResolvedPublic0 Estimated Story Points

Description

Current situation:
When typing a namepsace-name into the field the first item on the list isn't immediately preselected but actually in the background another list item is selected.

Screenshot_20180320_150721.png (284×779 px, 15 KB)

This results in a completely different item being added to the field when pressing enter in that situation. In this case discussion was added after pressing enter.

Screenshot_20180320_150950.png (128×747 px, 12 KB)

Also after adding and then removing a namespace, the preselection stays on the last selected item and not the top one either.

Screenshot_20180320_151142.png (273×751 px, 18 KB)

Task:
The preselection should always be the top item on the list, unless the user is moving down along the list with his cursor or up- and down buttons.

Criteria:

  • When the drop-down is opened for the first time the top item should be preselected.
  • When a tag was created and all options are shown again, the top item should be preselected.
  • While typing the preselected item should always be the top one of the list that the user currently sees.
  • When the user navigated the list with the up and down buttons the preselection should move accordingly and when the user presses enter the item that was visibly preselected to the user should be added as a tag.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I believe this is an upstream bug in OOUI. I do see two slightly different broken behaviors:

  1. Sometimes it depends on how much I type.
    • When I type a single character, e.g. "M", I can see that the options in the dropdown get reduced to the ones that start with "M", e.g. "MediaWiki", "MediaWiki talk", and so on.
    • But none is selected (no gray backgroud).
    • When pressing enter I realize what happens: there was still the previous selection active in the background, in this case "Article". This gets added when I press enter.
    • When I don't press enter but continue typing, e.g. "Me", the "MediaWiki" namespace gets highlighted now. It appears like some event handler is triggered to early or to late, and the code that updates the gray selection "lags behind".
  2. When I add and remove some namespaces, the behavior described in 1 breaks and not even the second character updates the selection.
    • I believe this might have something to do with the fact that the selection is stuck on a disabled list element (they get disabled the moment they are added).
    • I can see a bright blue highlight on one of the items, independent from the gray one I described in 1. What is this? When I make sure this is gone (e.g. by closing and reopening the dropdown), the behavior described in 1 is back.

Change 421849 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/AdvancedSearch@master] Unselect namespace dropdown items before disabling them

https://gerrit.wikimedia.org/r/421849

@Mooeypoo this is the ticket I was talking about

Change 439323 had a related patch set uploaded (by Mooeypoo; owner: Mooeypoo):
[oojs/ui@master] SelectWidget: Move 'highlight first item' to end of operation

https://gerrit.wikimedia.org/r/439323

The above commit should fix this behavior inside OOUI itself. Thanks for spotting it!

As far as I can tell, AdvancedSearch is not passing highlightOnFilter: true, so nothing ever should be preselected when filtering the input (or "highlighted", as we call it).

Items are only getting preselected/highlighted from MenuTagMultiselectWidget.prototype.onInputChange() → initializeMenuSelection(). That code was introduced fairly recently (T187398), and it seems to overlap the functionality of highlightOnFilter a bit… should be harmless though.


So, first of all, in mw.libs.advancedSearch.ui.NamespaceFilters you need to add highlightOnFilter: true after hideOnChoose: false :) That should fix this bug for you.

@Mooeypoo's patch does not fix anything for AdvancedSearch without that. But it actually fixes a different issue – with highlightOnFilter: true , previously navigating the menu with up/down arrow keys would not work (it would reset the highlight to first item every time).

Change 439323 merged by jenkins-bot:
[oojs/ui@master] MenuSelectWidget: Move 'highlight first item' to end of operation

https://gerrit.wikimedia.org/r/439323

kai.nissen set the point value for this task to 1.Jun 18 2018, 9:11 AM

@Mooeypoo @matmarex Thank you for your help!
Seems like the patch wasn't merged to master though. So now even if we set highlightOnFilter to true the arrow navigation would stop working.

@Tonina_Zhelyazkova_WMDE Fell sick whole last week and therefore there hasn't been an OOUI release with the patch merged on master yet, so it didn't make it into core either. Or did you test against anything home-made?

@Volker_E oh I looked at https://gerrit.wikimedia.org/r/439323 and saw it's +2ed but the post merge build failed, so I thought it's not even on master.

Change 421849 merged by jenkins-bot:
[mediawiki/extensions/AdvancedSearch@master] Unselect namespace dropdown items before disabling them

https://gerrit.wikimedia.org/r/421849

Seems like the patch wasn't merged to master though. So now even if we set highlightOnFilter to true the arrow navigation would stop working.

It's now released in OOUI v0.27.4 and MediaWiki was updated to use it, so you should be able to finally do that.

Change 443989 had a related patch set uploaded (by Gabriel Birke; owner: Gabriel Birke):
[mediawiki/extensions/AdvancedSearch@master] Preselect first item when searching for namespace

https://gerrit.wikimedia.org/r/443989

Lea_WMDE changed the point value for this task from 1 to 0.
Lea_WMDE moved this task from Todo to Blocked externally on the WMDE-FUN-Sprint-2018-07-09 board.

Change 443989 merged by jenkins-bot:
[mediawiki/extensions/AdvancedSearch@master] Preselect first item when searching for namespace

https://gerrit.wikimedia.org/r/443989