Page MenuHomePhabricator

Prevent the username suggestion list from opening if @ is preceded by a non-whitespace character
Open, Needs TriagePublic

Description

This task is about preventing the username suggestion list (T232601) from opening if the @ is preceded by a non-whitespace character.

This way, people can type things like email addresses and article names (e.g. 3D@Home) without having to interact with the username suggestion list.

This issue was reported by @Thryduulf at en.wiki here: https://en.wikipedia.org/wiki/Wikipedia_talk:Talk_pages_project#Feedback_request:_pinging_and_other_tools_in_source_mode.

Behavior

  1. Open the Reply or New Discussion Tool's Visual mode
  2. Type: hello@

Current behavior

  1. Notice that upon typing @, the username suggestion list appears

Desired behavior

  1. ✅ Notice that upon typing @, the username suggestion list does NOT appear

Note: the behavior above should also apply to the two tools' Source modes once T257391 is implemented.

Done

  • The 'Desired behavior" is implemented
  • @Thryduulf is notified

Event Timeline

Change 673521 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/DiscussionTools@master] Avoid triggering username autocompletion when typing email addresses and article titles

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

We previously did not do this because checking for "non-whitespace characters" doesn't really work in languages that don't use spaces to separate words, like Chinese or Japanese (T255153, T260443). But since this request keeps coming back, I investigated it more, and the proposed patch instead checks Unicode character properties and prevents opening if @ is preceded by characters classified as letters, combining marks, or numbers (https://unicode.org/reports/tr18/#General_Category_Property).

I am not completely sure that this will work fine in all possible languages, but it means that you'll get suggestions after any spaces or punctuation, e.g. "。" (Chinese full stop / ideographic full stop). Also, the mention button on the toolbar will open the username suggestions regardless of preceding characters, to allow inserting mentions even if that logic turns out to be wrong for some language.

Test wiki created on Patch Demo by ESanders (WMF) using patch(es) linked to this task:

https://patchdemo.wmflabs.org/wikis/4959dbaa9e/w/

prevents opening if @ is preceded by characters classified as letters

This means you can't @-mention in the middle of a sentence in Japanese, Chinese or Thai:

image.png (93×233 px, 3 KB)

I think the comments in T255153 are still valid.

It seems like the operation should be set by script rather than by letter/non-letter

(I had a go at this task because I was working on some other bugs related to mentions, and I thought this approach could work and we didn't consider it before, but it looks now like it might need more research after all.)

Change 673521 abandoned by Bartosz Dziewoński:
[mediawiki/extensions/DiscussionTools@master] Avoid triggering username autocompletion when typing email addresses and article titles

Reason:
Doesn't work as well as I hoped in languages using other scripts

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

Perhaps a way forward would be a per-user option with a per-wiki default. That should work on all wikis that use only one script, or multiple scripts of the same type (e.g. Latin and Cyrillic would both have a whitespace requirement as default, Chinese traditional and simplified would both not have that). Truly multilingual wikis would just have to pick one (I guess whichever suits whatever the majority of comments are written in) and advertise the config option.

matmarex subscribed.

Test wiki on Patch Demo by ESanders (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/4959dbaa9e/w/