Page MenuHomePhabricator

TagMultiselectWidget clears input before adding tag, causing validation failure in downstream widgets
Closed, ResolvedPublic

Description

When adding a new tag, addTagFromInput checks the validity of the input value, then, if valid:

  1. clears the input
  2. calls addTag

addTag then repeats the validity check, but after the input has been cleared.

This second check always fails for the UsersMultiselectWidget, because clearing the input fires a change event, which causes the menu to be cleared; and the validation checks whether value is in the menu. This means that the widget must accept arbitrary values, or else nothing can be entered.

(Incidentally, the second check only passes for the TitlesMultiselectWidget because the change handler clears the menu asynchronously on the next execution cycle, so addTag is called first.)

We can fix this by only clearing the input after a tag is successfully added.

Related Objects

Event Timeline

Change 565591 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[oojs/ui@master] TagMultiselectWidget: Fix some problems with addTagFromInput

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

Change 565591 merged by jenkins-bot:
[oojs/ui@master] TagMultiselectWidget: Add tags before clearing the input

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

Change 566898 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/core@master] Update OOUI to v0.36.3

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

Change 566898 merged by jenkins-bot:
[mediawiki/core@master] Update OOUI to v0.36.3

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

@Tchanders When you submit the Special:Investigate form, the usernames get cleared (although the data appears to get posted). This does not happen before the commit in T243075#5828523.

This also affects email-blacklist in Special:Preferences.

Volker_E edited projects, added OOUI (OOUI-0.36.3); removed OOUI.

Testing the Page and Namespace input in Special:Block and email-blacklist in Special:Preferences, comparing beta with test.

I focused on the behaviour when adding and removing tags and when input is validated and cleared.

I did not notice any discrepancies in behaviour of the inputs between beta and test, except those noted below.

We still have the same unfocus behaviour as it was implemented in T208507.

The differences I am seeing on beta:

  • I no longer see it attempting to validate the current input after removing a tag
  • When opening a form which already has input (e.g when editing a block), a menu appears with the currently selected tags (same as on Namespaces input). E.g.
    menuitemsnow.png (252×656 px, 10 KB)
  • For user multiselects (e.g. email-blacklist), I cannot add a tag of an invalid user (this is as desired in T238318)

Tested on Firefox 68 on beta (https://en.wikipedia.beta.wmflabs.org) and test (https://test.wikipedia.org).

I was somewhat exhausted by travel when testing this. It is possible I missed something...(maybe I will return to this later).