Page MenuHomePhabricator

PageForms: autocomplete not working for unicode chars
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • Create form with field like:
{{{field|field_fromsome_cargo|label=not working|input type=text with autocomplete|cargo table=CARGO_TABLE_NAME|cargo field=CARGO_FIELD_NAME|delimiter=; }}

What happens?:
Even when there are values in the cargo field, and mw.config.values.wgPageFormsAutocompleteValues is populated, the autocomplete is not working (due the lack of autocompletedatatype attribute)

What should have happened instead?:

The autocomplete should work

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
commit: 96ac11f453f1cf7b8f5759d5ac5b2f035328b786

Event Timeline

Change 768291 had a related patch set uploaded (by Anysite; author: Anysite):

[mediawiki/extensions/PageForms@master] combobox: Fix cargo autocomplete

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

I can't reproduce this bug - Cargo-based autocompletion works fine for me, in a variety of settings. I do have a few thoughts on this, and the patch:

  • The "text with autocomplete" input type is deprecated - really, you should have it be either "combobox" or "tokens". "text with autocomplete" should still work fine, but maybe that's the issue, I don't know.
  • If it's a combobox, there's no need to specify a "delimiter=" value. Again, I doubt that that's the problem, but who knows.
  • Your current patch checks for both "cargo field" and "cargo table" - I think "cargo table" is unnecessary.
  • Basically, I think your patch changes from "local" to "remote" autocompletion for all Cargo-based fields, if you know what I mean about that. So I think it's "local" autocompletion that is not working for you; though I don't know why. When you try it without this patch, do you see any JavaScript errors in the console?

Change 771894 had a related patch set uploaded (by Anysite; author: Anysite):

[mediawiki/extensions/PageForms@master] combobox: Fix cargo autocomplete

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

Change 771894 abandoned by Anysite:

[mediawiki/extensions/PageForms@master] combobox: Fix cargo autocomplete

Reason:

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

Sorry, a lot of mass because of geritt, this is the relevant commit:
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PageForms/+/771897

The problem is with utf8 chars, word boundry not working for them

Change 771894 restored by Yaron Koren:

[mediawiki/extensions/PageForms@master] combobox: Fix cargo autocomplete

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

@Yaron_Koren: what about this fix? Is this ever merged? Because autocomplete for unicode chars still not working.

I don't know - I'm not sure what to do here. I believe there are now three patches associated with this bug:

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PageForms/+/768291/
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PageForms/+/771894/
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PageForms/+/771897/

Are all three of these still relevant? If not, could you "abandon" the ones that are not?

Also, I think you never answered my questions, above.

Yep, I owe you explanation, sorry.

The bug is not caused by what I thought in the start. so this is irrelevant. (And so all your very good questions , sorry).

The problem is just in JS method that filtering the results by regex using word boundry flag \b. This is not working for unicode chars so when values are in Hebrew (for example) autocomplete (also combobox) never show results.
The solution is simply replacing \b with (^|\s) and for this, use this.

I'v abandoned the two others.

Change 768291 abandoned by Anysite:

[mediawiki/extensions/PageForms@master] combobox: Fix cargo autocomplete

Reason:

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

Okay, thank you. If you have time - could you fix both the commit message and this bug report's name, to clarify that this fixes autocompletion specifically for Unicode strings? (If I understand the problem correctly.)

Anysite renamed this task from PageForms: Cargo autocomplete not working in combobox to PageForms: autocomplete not working for unicode chars.Jun 16 2022, 8:21 PM

Sure thing. Done, is that good enough?

Sorry for the delay. Yes, the summaries are great now. I tried this out, and it works, but I do see one problem: it only checks for some of the word-break characters, but not all of them. You can see here the set of seven word-break characters that Page Forms autocompletion supports:

https://phabricator.wikimedia.org/diffusion/EPFM/browse/master/includes/PF_AutocompleteAPI.php$423

So, if you can add to the RegExp the remaining characters, this patch will be ready.

By DRY concept we should set this chars group in one place (I'm assuming in config entry in extension.json), Then call it from two places in the code.
Do you want me to do it like this, or just add it in JS?

I don't think it makes sense to have a setting for this group of characters. Given that, I think having it in two places is maybe not ideal, but fine.

Change 771894 merged by jenkins-bot:

[mediawiki/extensions/PageForms@master] combobox: Fix autocomplete for unicode chars

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

Yaron_Koren claimed this task.