Page MenuHomePhabricator

Add button to delete template in the context menu
Closed, DeclinedPublic5 Estimated Story Points

Description

Background
In T272482: Show/hide advanced toolbar when multi-part content is present the toolbar is hidden when editing a single template. There is a trashcan there which currently lets you delete a template from within the dialog. There is also a trashcan button which shows next to the template name in the main dialog when the sidebar is expanded. Both are removed or inaccessible by the new implementation. This means that the possibility of deleting the template within the dialog is changing from difficult to do to not possible. Instead, we will provide users the possibility of deleting when clicking on the template from editing the article (currently possible by clicking 'backspace/delete' on keyboard).

Requirements

  • Implement behind a feature flag with T272354: Add back button to VE TemplateDialog and T272355: Add unsaved changes warning message to VE TemplateDialog
  • Remove trash can next to template name in main dialog (if still there)
  • Use OOUI component: ButtonGroupWidget (destructive and progressive ButtonWidget) to add a second button with 'Delete' label which removes the template (same as clicking the delete or backspace button when template is selected). This button set-up should match the context menu for tables in VE, which also has a destructive and progressive button group.
  • Ensure that CTRL-Z still works as an undo to bring the template back (currently functions)

Mock

Context menu.png (106×426 px, 9 KB)

Related Objects

Event Timeline

ECohen_WMDE renamed this task from Add button to delete template in the context menu to DRAFT: Add button to delete template in the context menu.Feb 9 2021, 3:32 PM
ECohen_WMDE created this task.
ECohen_WMDE updated the task description. (Show Details)
ECohen_WMDE updated the task description. (Show Details)
ECohen_WMDE set the point value for this task to 5.
Lena_WMDE renamed this task from DRAFT: Add button to delete template in the context menu to Add button to delete template in the context menu.Mar 10 2021, 2:34 PM

For what it's worth, you shouldn't need to do any direct work to add a button. There's already code for having a standardized delete button on context items, it's just restricted to the MobileContext. If you look up ve.ui.MobileContext.static.showDeleteButton you can trace through how its display is triggered.

It'd be really easy to go big and just enable delete buttons on all non-mobile context items.

It'd also be simple to just override isDeletable on MWTransclusionContextItem -- check out TableContextItem for an example. So long as that's returning true, a delete button will show.

Change 691162 had a related patch set uploaded (by Andrew-WMDE; author: Andrew-WMDE):

[mediawiki/extensions/VisualEditor@master] Show a delete button only in the transclusion context menu

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

For what it's worth, you shouldn't need to do any direct work to add a button. There's already code for having a standardized delete button on context items, it's just restricted to the MobileContext. If you look up ve.ui.MobileContext.static.showDeleteButton you can trace through how its display is triggered.

It'd be really easy to go big and just enable delete buttons on all non-mobile context items.

It'd also be simple to just override isDeletable on MWTransclusionContextItem -- check out TableContextItem for an example. So long as that's returning true, a delete button will show.

@DLynch Thanks, this was very helpful!

@ECohen_WMDE I want to double-check that we intend to:

  • Remove trash can next to template name in main dialog (if still there)

even for multi-template transclusions? The new button has this effect for these entities:

image.png (141×532 px, 16 KB)

Clicking "Delete" will remove both templates. Now the main dialog is lacking delete buttons, and aren't we getting rid of the sidebar tool buttons which provided the last remaining template delete action?

Change 692284 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/VisualEditor@master] Introduce feature flag for template dialog sidebar changes

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

Change 692284 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Introduce feature flag for template dialog sidebar changes

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

Change 691162 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Show a delete button only in the transclusion context menu

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

@awight hopefully I've understood your question, but for mutlipart transclusions, the toolbar at the bottom of the sidebar (which includes a trashcan) will remain visible within an active editing session, until the changes are saved and closed. Therefore, it remains possible to delete (all) parts of a multipart transclusion from within the dialog, but via the toolbar not the trash icon next to the template name. Those requirements are listed in T272482: Show/hide advanced toolbar when multi-part content is present

As discussed in the daily this morning, I have updated the requirement related to the feature flag in this ticket. This should be moved to be behind a feature flag with T272354: Add back button to VE TemplateDialog and T272355: Add unsaved changes warning message to VE TemplateDialog, so that it can be deployed earlier, together with those changes. Thank you!

Change 693137 had a related patch set uploaded (by Andrew-WMDE; author: Andrew-WMDE):

[mediawiki/extensions/VisualEditor@master] Update the delete button's feature flag in the tranclusion context menu

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

Change 693137 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Update the delete button's feature flag in the tranclusion context menu

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

Esanders added a subscriber: Esanders.

I don't understand the logic behind this change. In VE, all focusable nodes are deleted using backspace or delete on desktop. If there is an issue with discoverability, then this should be changed for all nodes. Templates are now inconsistent with other focusable nodes:

  • Images, galleries
  • Extension content (Math, Syntax block)

None of these nodes have a way to delete themselves from within their dialogs, so the argument made in the original task would apply to these too.

Template (deletable):

image.png (133×424 px, 16 KB)

Image (not deletable):

image.png (177×420 px, 16 KB)

The only context on desktop which has a need for delete button is the table context, as pressing delete with a table selection only deletes the contents of the selected cells:

image.png (106×424 px, 6 KB)

Change 772033 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/VisualEditor@master] Remove delete button from template context

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

@Esanders The delete button of the context for tables also deletes the entire table, not just the contents of the selected cells. This is the precedent we were following, so if that behaviour is not as intended then it is broken at the moment (and for some time already, since we shared this with you and the team, and tested and implemented it over half a year ago). However, with the addition delete button for the template context, we actually implemented that behaviour for template content within a table.

Screen Shot 2022-03-21 at 09.03.30.png (400×617 px, 67 KB)

@ppelberg could you provide input on this?

Yes - that is what I was saying. The table context needs a delete button because you can't use the keyboard to delete an entire table. The template, like other focusable nodes (other than tables) does not need a delete button because you can use the keyboard. There is no precedent for having a delete button for focusable nodes on desktop.

we actually implemented that behaviour for template content within a table

These can also be deleted using the delete button, but it would be inadvisable as it would likely leave the table in an invalid state with no obvious way to fix it, so making the delete action more prominent is not a good idea (as well as being inconsistent as described above).

Summary:

  • The original task described that "the possibility of deleting the template within the dialog is changing from difficult to do to not possible".
  • The delete action was removed because it was not considered that useful. This task proposed replacing it with an arguably more prominent action.
  • The delete action in context items was only ever intended for mobile (where the keyboard is unavailable) or special cases like tables, where cell contents are deleted by the keyboard.
  • We have never received any user feedback that focusable nodes (e.g. images, templates) are hard to delete, so I see no reason why we would want to add a delete button on desktop at this time.

since we shared this with you and the team, and tested and implemented it over half a year ago

I'm sorry this was missed at the time. I will note that although this was merged some time ago, it was only deployed to enwiki 2 weeks ago: https://gerrit.wikimedia.org/r/c/operations/mediawiki-config/+/767508 (and also our beta test environments)

@Esanders The delete button of the context for tables also deletes the entire table, not just the contents of the selected cells. This is the precedent we were following, so if that behaviour is not as intended then it is broken at the moment (and for some time already, since we shared this with you and the team, and tested and implemented it over half a year ago). However, with the addition delete button for the template context, we actually implemented that behaviour for template content within a table.
@ppelberg could you provide input on this?

@Lena_WMDE thank you for the ping and thank you, @Esanders for the summary (T274263#7792729).

Assuming the understanding I've come to is accurate and exhaustive (see Thinking below), then I support what Ed is proposing in 772033:

  1. REMOVE the Delete button from the context item that appears when people place their browser's cursor on/within all focusable nodes (e.g. templates, images, galleries, math formulas, etc.) on desktop.
  2. RETAIN the Delete button that appears within the context item that appears when people place their browser's cursor on/within a table on desktop.

Thinking

  1. Change this task was originally proposing: ADD a Delete button to all context items that appear when, on desktop, people place their browser's cursor on/within any focusable node (e.g. templates, images, galleries, math formulas, etc.).
  2. Motivations for implementing the "change" mentioned in "1.":
    • A) Adding the Delete button "1." proposes, is necessary for people to be able to delete an image, math formula, template, etc. (read: focusable node)
    • B) Adding the Delete button "1." proposes, is aligned with VE's existing design patterns [i]

The combination of...

  • Knowing that "2A)" is not accurate (people can delete images, math formulas, etc.) using Backspace,
  • Assuming that people intuitively know to use Backspace to delete an image, math formulas, template, etc.,
  • Not being aware of usability research and/or qualitative feedback that suggest this assumption is inaccurate, and
  • Learning that the Delete button being shown with the context item that accompanies tables is an exception to the rule, rather than the rule "2B)" suggests it to be

...leads me to be unclear about the value of deviating from the current behavior of not showing Delete buttons with context items on desktop, except for the context item that appear when people place their browser's cursor within a table.[ii]


i. "...the delete button of the context for tables also deletes the entire table, not just the contents of the selected cells. This is the precedent we were following." | See: T274263#7791674
ii. I appreciate it is likely there is value this change could unlock that I am not currently seeing (if you have thoughts in mind around this, please comment as much!). Tho, in this moment, the risks are most clear to me (e.g. increasing the likelihood that someone inadvertently deletes content they were wanting to edit)

Assuming the revert patch [i] does not introduce any unexpected behavior, can it be merged?

@awight I appreciate you naming the need for product approval in gerrit [ii]. After talking with @Lena_WMDE about T274263#7795089 briefly offline, I am comfortable saying that the revert patch has product approval.

Note: Lena and I will be talking sometime in the next 2-3 weeks about how and why we ended up in the position of needing to revert this change.


i. https://gerrit.wikimedia.org/r/c/mediawiki/extensions/VisualEditor/+/772033
ii. https://gerrit.wikimedia.org/r/c/mediawiki/extensions/VisualEditor/+/772033/2#message-824f2771c6f396d6c368dff3b95d3c7f50162932

I've verified that our new features still work on a technical level, and done my best to verify that the interface is usable. Although WMDE's recent work takes away the in-dialog template deletion buttons in the simplest use case of a single-template transclusion, there are still means to delete a template on desktop (<delete> key) and mobile (delete button is still available in the context menu).

Thank you @Esanders and @ppelberg for taking such care to check with our team before reverting!

Change 772033 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Remove delete button from template context

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

I think we can close this again. The new decision is to not add the button after all, so I'll mark it as Declined.