Page MenuHomePhabricator

MenuTagMultiselectWidget unexpectedly removes card if invalid input is entered after the field loses focus
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Go to the OOUI demo page https://doc.wikimedia.org/oojs-ui/master/demos/
  • Scroll to MenuTagMultiselectWidget (initially selected, preset options)
  • Type something invalid, e.g. "foobar"
  • Click outside of the field, so that it loses focus
  • Focus the field again by clicking
  • Hit enter

What happens?:
A card will disappear from the widget, and whatever you typed will also be cleared.

What should have happened instead?:
This I don't know. I would say that hitting enter should not change (add or remove) any cards; I guess the main question is what should happen to the invalid text, i.e., whether it should be cleared or not. Maybe it shouldn't, but again, I don't know for sure.

Software version (skip for WMF-hosted wikis like Wikipedia):
OOUI v0.46.3

Event Timeline

Change 891811 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[oojs/ui@master] Improve confusing ENTER behavior in MenuTagMultiselectWidget

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

This is not exactly an error. The same happens when you don't type anything. Just focus the field and hit enter.

What happens is that the dropdown menu opens with the first element being highlighted and pre-selected the same time. Enter toggles the selection for the currently highlighted item and either adds or removes it from the list of tags. The code responsible for this intended behavior can be seen here: https://gerrit.wikimedia.org/r/c/oojs/ui/+/891488/2/src/widgets/SelectWidget.js

The invalid, red text is entirely ignored in this situation and just disappears. What makes this confusing is that multiple things happen the same time.

Turns out this is related to T295885. I uploaded a patch where I suggest a slightly different behavior that should be easier to follow.

This is not exactly an error. The same happens when you don't type anything. Just focus the field and hit enter.

What happens is that the dropdown menu opens with the first element being highlighted and pre-selected the same time. Enter toggles the selection for the currently highlighted item and either adds or removes it from the list of tags. The code responsible for this intended behavior can be seen here: https://gerrit.wikimedia.org/r/c/oojs/ui/+/891488/2/src/widgets/SelectWidget.js

Ooooooh, I see, you're right! This is indeed quite confusing. I guess it's fine if there's no "pending" input, but otherwise I didn't understand what was going on.

Change 891811 merged by jenkins-bot:

[oojs/ui@master] Improve confusing ENTER behavior in MenuTagMultiselectWidget

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

Change 921070 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/core@master] Update OOUI to v0.47.0

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

Change 921070 merged by jenkins-bot:

[mediawiki/core@master] Update OOUI to v0.47.0

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

matmarex assigned this task to thiemowmde.

I assume that fixed it.