Page MenuHomePhabricator

Lexemes: Grammatical form can render as `[object Object]`
Closed, ResolvedPublic5 Estimated Story Points

Description

Steps to reproduce:

  1. Visit a lexeme (eg https://www.wikidata.org/wiki/Lexeme:L123, a sandbox lexeme)
  2. Under Forms, either select add Form, or edit an exist one
  3. In the Grammatical features field, search for and select any element (eg "Sandbox")
  4. Hit the backspace key

Expected result:
Grammatical feature chosen is deleted (same as if the "x" had been clicked)

Actual result:
The visual element for the grammatical feature chosen is replaced with the characters [object Object], which must be removed manually

Notes:
This seems to be related to:

Event Timeline

I was working on T249167 and T258337 and found what causes this: Never call setLabel() with anything but plain text. When you want a more complex HTML label, do it like this:

new OO.ui.Widget( {
	label: 'Plain text',
	$label: $( '<a>' ).attr( { 'href': '…' } ),
} );

Or like this:

// This is exactly what the LabelElement constructor does
widget.setLabel( 'Plain text' );
widget.setLabelElement( $( '<a>' ).attr( { 'href': '…' } ) );

In both cases the plain text label and the HTML element that wraps the text are passed in separately.

This is a workaround that avoids any of the broken code in setLabel().

Change 618729 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[oojs/ui@master] Fix several broken code paths related to LabelElement#getLabel

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

Change 811308 had a related patch set uploaded (by Guergana Tzatchkova; author: Guergana Tzatchkova):

[oojs/ui@master] Fix Lexemes: Grammatical form can render as `[object Object]`

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

An easy way to test this patch is to directly edit the JS files in MediaWiki, copying the portion added in the patch to mediawiki/core/resources/lib/ooui/oojs-ui-widgets.js

Once this is merged, we could mark T220093 as solved because it wouldn't be an issue if the jquery object is passed. The uploaded patch adds the case that a jquery object.

Change 811308 merged by jenkins-bot:

[oojs/ui@master] TagMultiselectWidget: Support editing tags with jQuery-formatted labels

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

Gerrit patch 811308 has been merged, the next step for fixing this bug is to create a release so we can update the current version of oojs/ui in mediawiki. @Jdforrester-WMF @matmarex should I upload a patch requesting a release or when do you estimate that a new release will be made? :)

Gerrit patch 811308 has been merged, the next step for fixing this bug is to create a release so we can update the current version of oojs/ui in mediawiki. @Jdforrester-WMF @matmarex should I upload a patch requesting a release or when do you estimate that a new release will be made? :)

I don't know, @Jdforrester-WMF and @Volker_E do the releases.

If you need the fix urgently, you could also manually backport the patch to the vendored copy of OOUI we have in mediawiki/core, by building it locally and copying the result over to resources/lib/ooui/oojs-ui-widgets.js (or manually applying the changes there if you have trouble building it for any reason).

ItamarWMDE changed the task status from Open to Stalled.Jul 13 2022, 12:04 PM

Change 813630 had a related patch set uploaded (by Jforrester; author: Jforrester):

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

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

Change 813630 merged by jenkins-bot:

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

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

Change 813905 had a related patch set uploaded (by Guergana Tzatchkova; author: Guergana Tzatchkova):

[mediawiki/extensions/WikibaseLexeme@master] Remove TODO comment since T239208 allows for labels to be Objects

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

Change 813905 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] Remove TODO comment since T239208 allows for labels to be Objects

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