← Tasks
Mentions - autocomplete
Adding UI to let you select a user from a list when @-mentioning. Requires completion of Stage 1.
Desired UX
- User types @ in a text area
- Dropdown showing possible matches appears, best match is highlighted
- User can keep typing as usual or press ENTER/TAB/LEFT CLICK to select and insert the best match
- Dropdown closes automatically on selection of best match or insertion of non-alphanumeric character (signalling end of mention)
Important points:
- typing @ directly after a non-space character will not start matching as this is not a valid username
- possible matches are drawn from the workspace members. i.e. You can’t mention anyone who is not in the current workspace
- Dropdown only shown when possible matches has <=5 options to select from
- Clicking anywhere outside the dropdown will close the dropdown
Technical considerations
- We will fetch the usernames list on the first attempted mention and then not-refetch, so there will be a slight delay on first mention, but none after that
- We need to calculate the cursor position within the text area for the dropdown positioning - investigate
- To find the possible and best matches, we can either search for substrings or use something like Levenshtein Distance, we’ll start with substrings for simplicity
Steps
-
Detect mention start / end -
Update possible matches based on current mention (using hardcoded list, no dropdown) -
Select best match using tab/enter (no dropdown) -
Cycle through selected match using arrow keys -
Display possible matches in dropdown -
Fetch and populate username list at start of first mention -
Add mention support to new comment form -
Add mention support to edit comment form -
Release!