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:
Guiding principles
The design we implement should increase the likelihood of the following two things being true:
- The username results list makes it possible for people to quickly and easily find the person they are wanting to notify.
- The username results list makes it clear to people how to find the username of someone who is not currently shown.
Requirements
This section describes how the first iteration of this feature should function.
- When someone types @ , the username completion list should show the usernames of the people who have commented in the section where the reply is being drafted.
- The usernames in the results list will be sorted alphabetically.
- Usernames will appear in the username results list exactly as they appear in the database not as they appear in the page. Meaning, if someone has a custom signature (read: alias) such that the username that is appended to the comments they post on talk pages [1] is different from the username that appears in the link to their user page [2], their alias will not show up in the username results list.
- We will explore making it so aliases appear in the username completion list in this task: T250329.
- The moment someone types @ + any other character, the username results list will return results (read: usernames) of the registered users on the wiki that resemble the username the person invoking auto-complete has typed.
- Meaning, the suggestion list will start returning results as soon as people start typing and the list of results will update dynamically without needing to wait for a full-word match to be made.
- Example: Typing @pe should return "peter", but not "snape"
- We will explore implementing more robust search functionality in this task: T250334.
- People can select a username from the username results list in either of the following ways:
- Use arrow keys (↑ or ↓) to highlight the specific person + press ⏎ to complete selection
- Use mouse to highlight the specific person + click to complete selection
- Note: we are limiting selections to explicit actions (e.g. ⏎ or mouse click) because username conventions (e.g. spaces) make it difficult to correctly assume when the software should stop searching for matches.
- When you select a username from the username results list, the following will show up in the reply text input:
- Link: link to selected user's user page
- Display text: @ + selected user's username (the display text should be the same as what is shown in the username results list.)
- Here is the task for exploring whether this behavior should be configurable: T250332.
- When you select a username from the username results list for someone who has not yet created a user page, their username will appear as a red link both when the comment is being drafted and when the comment is published to the talk page.
- In source, people will see the red-linked username in the preview; in visual, people will see it in the text input area
- Whether or not someone has created a user page should not affect whether they receive a notification or not.
- When a comment is posted containing a valid link(s) to other user pages, those "mentioned users" should receive an "Alert" in the format described in Help:Notifications/Types#Mentions
- The username completion list should be dismissed and typed text remain in place when:
- escape is pressed
- space is pressed immediately after typing @
- People should be able to trigger a ping when they type an exact match
- Where "exact match" means: @exactusername<space>
Open questions
- 1. What are the different ways the in-surface picker can be initiated (typing @, clicking the "👤" in the Visual mode's toolbar, etc.)
- Per T232601#6091882, in the initial version, there will be one way to initiate the username suggestion list: typing @. Read: there will not be a "👤" or analogous icon in the visual mode toolbar to start.
- 2. What should the username picker look like? How should it be have (e.g. how should results be populated?)?
- Creating the UI will happen in: T251478; how the username suggestion list should behave is described in "Requirements" (above).
- 3. What is going to be inserted into the page once a user is "picked" (e.g. a template like {{FlowMention:NAME|NAME}}, link to their user page [[User:NAME|NAME]] )
- Per T232601#5960614, currently a link to the person being mentioned's user page is inserted. In the future, we will consider enabling wikis to customize this behavior. That work would happen in: T250332.
- 4. When @ is typed, should the username completion list show the username of people who have commented in other sections on the page?
- No. When @ is typed, the username completion list should show the usernames of the people who have commented in the section where the reply is being drafted. Thinking: T232601#6073976.
- 5. Will you be able to ping/@-mention people who have not created user pages?
- Yes and their username will appear as a red link. See T232601#6073962 for details.
- 6. Will the whitespace the tool can add to the page (e.g. T249958) affect its ability to send pings?
- We do not think it will.