Page MenuHomePhabricator

LookupInputWidget is terrible and also sucks
Closed, ResolvedPublic

Description

Brain dump:

  • The constructor called like OO.ui.LookupInputWidget.call( this, this, config ) is stupid – fixed with https://gerrit.wikimedia.org/r/184828
  • The name is wrong – should be InputLookupWidget maybe, or just LookupWidget? It is not a subclass of InputWidget.
  • The methods #getLookupCacheItemFromData and #getLookupMenuItemsFromData actually accept different data as input – in fact, one takes the output of the other (see example: T85467#975078)
  • The #onLookupMenuItemChoose method has to be reimplemented in every child, while in 90% of cases it should just set the value of textbox to the chosen suggestion (pointed out by @Ricordisamoa)

Event Timeline

matmarex raised the priority of this task from to Medium.
matmarex updated the task description. (Show Details)
matmarex added a project: OOUI.
matmarex added subscribers: matmarex, Osnard, Ricordisamoa and 4 others.

I would really like to fix these, but @Jdforrester-WMF is already mad at me for making https://gerrit.wikimedia.org/r/184828 breaking ;), so here's a proposal: we revert that, we deprecate LookupInputWidget and generally cast it into oblivion, we create a new pretty InputLookupWidget that fixes the issues above, and we replace uses of old one with the new one (the only user currently is VisualEditor and @Jdlrobson's unmerged MobileFrontend change).

Thoughts?

Also, onLookupMenuItemChoose is not a standard method, it has to be bound with this.lookupMenu.connect().

Are there any use cases of LookupInputWidget which don't involve inheriting from TextInputWidget?

Are there any use cases of LookupInputWidget which don't involve inheriting from TextInputWidget?

Yes, VisualEditor's ve.ui.MWLinkTargetInputWidget (which mixins a LookupInputWidget) inherits from ve.ui.LinkTargetInputWidget (and that inherits from TextInputWidget).

Talked with @TrevorParscal and we probably want to call it… LookupElement. Fits better with other mixins' names.

gerritbot subscribed.

Change 185110 had a related patch set uploaded (by Bartosz Dziewoński):
Revert "[BREAKING CHANGE] LookupInputWidget: Remove the silly 'input' parameter"

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

Patch-For-Review

matmarex raised the priority of this task from Medium to High.Jan 15 2015, 1:30 AM

Change 185110 merged by jenkins-bot:
Revert "[BREAKING CHANGE] LookupInputWidget: Remove the silly 'input' parameter"

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

Further issues:

  • The lookup menu doesn't have z-index (?) high enough to display on top of other widgets, unlike the one in DropdownWidget and its kin
    pasted_file (707×297 px, 13 KB)
  • Should probably call #isValid before triggering the lookup queries?

Further issues:

  • The lookup menu doesn't have z-index (?) high enough to display on top of other widgets, unlike the one in DropdownWidget and its kin
    pasted_file (707×297 px, 13 KB)

This issue is still a blocker for my use cases.

  • Should probably call #isValid before triggering the lookup queries?

I don't think so, for example the validity regex could be /\w{3,}/ and the user might try to type a single letter to get suggestions.

I don't think so, for example the validity regex could be /\w{3,}/ and the user might try to type a single letter to get suggestions.

Hmm, okay.

Change 185254 had a related patch set uploaded (by Bartosz Dziewoński):
Replace old&busted LookupInputWidget with new&hot LookupElement

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

Patch-For-Review

Thank you for the really useful comments! :D

Change 185257 had a related patch set uploaded (by Bartosz Dziewoński):
[BREAKING CHANGE] Remove deprecated LookupInputWidget

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

Patch-For-Review

Change 185254 merged by jenkins-bot:
Replace old&busted LookupInputWidget with new&hot LookupElement

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

Change 185257 merged by jenkins-bot:
[BREAKING CHANGE] Remove deprecated LookupInputWidget

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