Page MenuHomePhabricator

Provide a mechanism for in-surface autocomplete
Open, Needs TriagePublic

Description

Currently there is no way to provide autocomplete suggestions while the user is typing directly in the document. This technique is commonly used for '@' mentions:

Phabricator (desktop)Twitter (mobile)

The lack of this feature has led to a workaround in Flow which uses an inspector triggered by an '@' sequence, but this results in a clunky user experience, and bugs such as T147408:

Some initial requirements for an autocomplete module

  • Define a sequence for launching, probably re-use the ve.ui.Sequence system, which allows for generic regex matching
  • The process is aborted if:
    • Escape is pressed
    • Some other configurable sequence is typed, e.g. a space immediately after '@'
  • If the process is aborted, the text typed so far should be left as is.
  • The process is successful if:
    • A result is selected using arrow keys + enter, or mouse click
    • An exact match is typed e.g. @exactusername<space> (this could be optional)
  • If the process is successful, then a replacement can take place, e.g. format the text with a link/other annotation, or replace with a template

Details

Related Gerrit Patches:
VisualEditor/VisualEditor : master[WIP] Completion framework
mediawiki/extensions/VisualEditor : master[WIP] Username completion action, split out
mediawiki/extensions/VisualEditor : masterCompletion framework

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 11 2019, 11:53 AM
Esanders updated the task description. (Show Details)Sep 11 2019, 12:08 PM
Esanders updated the task description. (Show Details)
Esanders updated the task description. (Show Details)Sep 11 2019, 12:12 PM
Esanders assigned this task to DLynch.Sep 12 2019, 8:23 PM
Esanders edited projects, added VisualEditor (Current work); removed VisualEditor.

I have a script for autocomplete suggestions (not for @user, but for words already in the text): https://de.wikipedia.org/wiki/Benutzer:Schnark/js/veSuggestions.js
(German) documentation (including screenshot) is on https://de.wikipedia.org/wiki/Benutzer:Schnark/js/veSuggestions
If you want to reuse any code from there, feel free to do so.

Thanks, that's very cool. I made a fork with some improvements: https://en.wikipedia.org/w/index.php?title=User:ESanders_(WMF)/veSuggestions.js&action=history (feel free to merge them across)

We should keep this use case in mind and hopefully whatever we build will be generic enough to support this sort of word suggestion.

ppelberg added a comment.EditedSep 30 2019, 5:57 PM

This is neat and opening up many ideas. Documenting a couple here:

  • A slash-like command for easily linking/referring to a recent edit (e.g. Lombard Street talk)
  • A slash-like command for easily linking/referring to a policy page/shortcut

Change 540436 had a related patch set uploaded (by DLynch; owner: DLynch):
[VisualEditor/VisualEditor@master] [WIP] Completion framework

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

Change 540437 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/VisualEditor@master] [WIP] Username autocomplete via completion framework

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

Change 550897 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/VisualEditor@master] [WIP] Username completion action, split out

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

That last patch is a not-to-be-merged-but-useful-to-exist-for-testing one. The actual username completion will exist over in DiscussionTools, but that's not actually in a state where it's easy to use yet.