This task is about implementing specific "inspection behavior" [i] for wikilinks to user pages within #DiscussionTools.
=== Context
Links to user pages are syntactically the same as other [wikilinks](https://en.wikipedia.org/wiki/Help:Link#Wikilinks): `[[` `Namespace:` `page` `|` `display text` `]]`.
|User page link syntax| Other wiklink format|
| --- | ---
| `[[User:NAME|NAME]]` | `[[Help:LINK|LINK]]`
Although, links to user pages behave differently from other wikilinks. Namely, when links to user pages are saved to the page, the person whose user page was linked to will receive an "Alert" as described here: https://www.mediawiki.org/wiki/Help:Notifications/Types#Mentions. The same is **not true** when any other kind of wikilink is saved to the page.
Trouble is, as T232601 is currently implemented, user page links and other wikilinks behave the same. Should this behavior persist, we think people could become confused about how user page links (read: pings) work. For example, they could mistakenly change the display text of a link, assuming that doing so would change who gets a notification.
=== Requirements
//People should be able to://
- Remove a "ping" from the comment they have drafted
- Change who they are "pinging" (read: change ping from `USER 1` to `USER 2`) without having to delete the entire contents of the previously written "ping"
- Understand "pings" as being different from other links
=== Approaches
**Approach #1A: temporary block that remains a link**
- Implementation
-- //When an @-mention is selected in the Reply tool's `visual` mode://
--- People would see block that describes its contents with no calls to action, similar to how VE handles signatures
--- The entirety of the block could be deleted
--- The block's contents could not be edited
--- //@DLynch describes this in more detail in T252083#6114939)//
-- //When an @-mention is selected in the Reply tool's `source` mode://
--- People would see `@[[User:NAME|NAME]` and be able to edit it like any other wikilink
- Considerations
-- Works independent of templates
-- The @-mention would look and behave like a regular link if someone were to go from `Visual` --> `Source` --> `Visual` //and// if you were to edit an old comment.
**Approach #1B: block that is treated as a template**
- Implementation
-- //When an @-mention is selected in the Reply tool's `visual` mode...//
--- People would see a block that describes its contents and includes an "Edit" call to action that, when clicked, shows a special UI for editing the template's contents
-- //When an @-mention is selected in the Reply tool's `source` mode://
--- People would see something like `{{DiscussionTool ping|NAME}}` and be able to edit it like any other template
- Considerations
-- Always editable later
-- Local templates would need to be configured on every wiki (one-time cost)
**Approach #2: leave pings as links; present a special UI for editing/inspecting**
- Implementation
-- //When an @-mention is selected in the Reply tool's `visual` mode...//
--- People would see a dialog specific to pings that could be customized, similar to what can be found when using Flow [ii]
--- This would enable people to edit/modify who they are pinging without needing to delete the entirety of the ping they'd previously written.
-- //When an @-mention is selected in the Reply tool's `source` mode...//
--- People would see `@[[User:NAME|NAME]` and be able to edit it like any other wikilink
- Considerations
-- Works independently of templates
-- Flexibility for defining new interactions (backspacing, cursoring in)
**Approach #3: leave pings as links; present same UI that is shown for all other links**
- Implementation
-- //When an @-mention is selected in the Reply tool's `visual` mode...//
--- People would see a link dialog like any other [iii]
--- Ping/link's display text could be edited independent of its target
--- Ping/link could be removed entirely
--- A new user could be searched for
-- //When an @-mention is selected in the Reply tool's `source` mode...//
--- People would see `@[[User:NAME|NAME]` and be able to edit it like any other wikilink
- Considerations
-- Could make it more likely for the ping/link's display text and target to be out of sync (as @Esanders here: T252083#6115759)
-- Could lead people to become less confident what they have written will notify someone else, as they're expecting it to.
=== Open questions
- [ ] 1. How should the tool behave when someone places their cursor inside the user link?
-- //Current behavior: the link inspector dialog appears.//
- [ ] 2. How should the tool behave when someone backspaces into user link?
-- **i.** Select `@Asparagus` from username suggestion list such that `[[User:Asparagus|@Asparagus]]` appears in the Reply's text input area
-- **ii.** Press {key delete} into the user link
-- **iii. ???** (//Current behavior: the link inspector dialog appears.//)
- [x] 3. Can you change the display text without changing the link target?
-- No, you should not be able to change the display text without changing the link target within the Reply tool's `visual` text input mode (this will still be possible in `source` mode).
--- //Rationale: Changing the display text could make it more difficult for people reading and participating in the conversation to understand what is happening because of it not being clear who a comment is directed to. Based on what I've observed so far, it seems to be common practice to refer to someone by the username they've defined for themself.//
=== Done
- [ ] "Open questions" are resolved
- [ ] "Requirements" are implemented
---
i. E.g. placing your cursor into a user page wikilink, backspacing into a user page link, etc.
ii. Example of what leaving pings as links and presenting a special UI could look like and behave: {F31813019}
iii. Current UI {F31813040}