Problem/Motivation

In most cases, entity delete confirmation forms are very simple and there's no reason why we should make the user go to a different page just for this.

Proposed resolution

Update all links to the entity delete confirmation form so as to use a modal by default.

Links to delete entities via operation links (for example on the admin/content page) are being handled as a separate issue: #2253257: Use a modal for entity delete operation links.
The scope here is to tackle the rest.

Remaining tasks

User interface changes

Clicking on entity delete links on the edit form or delete tab should bring up the confirmation form in a modal.

API changes

None.

Data model changes

None.

Comments

xano’s picture

Status: Active » Needs review
StatusFileSize
new1.64 KB
larowlan’s picture

Looks like the question isn't coming through as the title.
screenshot

xano’s picture

That is because of #2255369: DialogController does not respect $content['#title'] for the page title. The question doesn't fit the space the modal reserves for the title, though.

xano’s picture

StatusFileSize
new670 bytes
new1.92 KB

This makes sure that long titles are displayed correctly by the modal. However, many entity delete pages have <em> in their titles, which isn't properly displayed by the modal, but that's for another issue as well.

larowlan’s picture

xano’s picture

So is this good to go?

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Yes

olli’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.95 KB
new1.61 KB
+++ b/core/lib/Drupal/Core/Form/ConfirmFormHelper.php
@@ -62,6 +63,13 @@ public static function buildCancelLink(ConfirmFormInterface $form, Request $requ
+      'data-dialog-options' => Json::encode(array(
+        'width' => 'auto',
+      )),

Shouldn't this be in the delete link?

xano’s picture

Status: Needs review » Reviewed & tested by the community

You're right. Thanks for being so observant!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: drupal-2254935-8.patch, failed testing.

xano’s picture

Status: Needs work » Reviewed & tested by the community

Ugh. Another testbot malfunction.

alexpott’s picture

8: drupal-2254935-8.patch queued for re-testing.

Bojhan’s picture

I am not a huge fan of confirm dialogs, as they turn into a habit even when it concerns critical messages. However I don't see the current step as a bad thing. I have a few questions:

  • Does this work well on mobile? I am not sure how well tested our confirm dialogs are.
  • Shouldn't we also do this with configuration forms, it seems like going without that will create quite a inconsistency. Also I assume that will be much harder.
xano’s picture

I have no idea how configuration forms are related to this issue, as they are not entity forms and have no delete links. Can you elaborate on that?

lewisnyman’s picture

The confirm dialog is a global component, if it's not mobile friendly yet then we need to fix that globally. It shouldn't affect the decision to use a dialog on a case per case basis.

yoroy’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new30.72 KB

Deleting something should follow a consistent pattern, regardless if it's an entity or not. For example, deleting an URL alias has a confirmation step similar to the one for entities:

Screengrab of URL alias edit form

yoroy’s picture

Lewisnyman: the question is whether a case-by-case approach helps us closer to release. Not sure it does.

xano’s picture

This patch does not remove the confirmation step. It just presents that step as a modal rather than a separate page when people click the Delete link from the entity form (#2253257: Use a modal for entity delete operation links is for the operation link in entity lists). Is this what you mean? I just want to make sure since there has been some confusion.

If this is what you mean, do you have any suggestions? Should we keep confirmation pages for deletion workflows, or should we implement modals across the board straight away?

yoroy’s picture

Understood that the confirmation step stays. I meant to say that *the process of deleting something* (entity or whatever) in the UI should follow the same pattern. Moving it into a modal for only some of the delete operations makes it less consistent.

I have no objections to the use of the modal itself. Just cautious to apply it only in some places, some not.

yoroy’s picture

Ok, so best next step seems to be to get a list of the non-entity delete forms in core that would not be touched by this patch so that we can see how many exceptions we'd introduce and assess how bad that might be.

xano’s picture

Agreed.

xano’s picture

Berdir queued 8: drupal-2254935-8.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 8: drupal-2254935-8.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

rolodmonkey’s picture

Version: 8.3.x-dev » 8.4.x-dev
Assigned: Unassigned » rolodmonkey

Since the parent issue is for 8.4, I am updating this one to be the same.

vijaycs85’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
StatusFileSize
new111.6 KB
new1.71 KB

Re-roll against 8.4.x.

vijaycs85’s picture

StatusFileSize
new69.79 KB

Also the space between the delete link and loading icon seems bit too much. Attaching screenshot.

Status: Needs review » Needs work

The last submitted patch, 29: 2254935-29.patch, failed testing.

vijaycs85’s picture

Status: Needs work » Needs review
StatusFileSize
new964 bytes
new2.65 KB

Updating test fail.

droplet’s picture

Jot a quick note:

I think we need to test nested Modal with this new feature.

Status: Needs review » Needs work

The last submitted patch, 32: 2254935-32.patch, failed testing.

manuel garcia’s picture

Assigned: rolodmonkey » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.79 KB
new3.74 KB

Fixing the failing tests, and expanding a bit the tests on there to check for the modals.

Re: #33: I think nested modals are not working in core at the moment, see #2741877: Nested modals don't work: opening a modal from a modal closes the original

vijaycs85’s picture

vijaycs85’s picture

Title: Use a modal for the entity form delete link » Use a modal for content entity form delete link
yoroy’s picture

One quick note is that this only seems to work from the delete link while already editing the thing. There's a "Delete" tab on the front-end view of content items where I'd expect the same behaviour but no modal there (yet).

manuel garcia’s picture

@yoroy my understanding is that this issue is for the entity edit form only.

Another place that is not covered by this patch would be the delete link on the operations links (for example on the /admin/content view)

In any case, I agree from a UX perspective that we should do this for any link pointing to a delete entity form so that it is the same expected behavior.

I guess the question is: Should we expand the scope of this issue or not?

rolodmonkey’s picture

The other ways to delete content are already being handled in separate issues. Please scroll to the top of this issue and see the parent issue and related issues.

yoroy’s picture

Once more proof people don't see things in sidebars :) I see that is covered indeed.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

manuel garcia’s picture

We've got functional javascript tests covering the functionality introduced, so removing the tags.

Latest patch still applies cleanly, anything else we should be doing here?

manuel garcia’s picture

StatusFileSize
new675 bytes
new3.76 KB
+++ b/core/lib/Drupal/Core/Entity/EntityForm.php
@@ -244,10 +245,15 @@ protected function actions(array $form, FormStateInterface $form_state) {
+          'data-dialog-options' => Json::encode(['width' => 'auto'])

We're standardizing on width 700 for core here, so fixing that. Also moving that to a new line so as to keep the same format as elsewhere in core.

runeasgar’s picture

Status: Needs review » Reviewed & tested by the community

Testing.

  1. Confirming undesirable behavior by creating an article, and deleting it: confirmed. I am taken to a page with the option to delete.
  2. Applying patch: $ curl -l https://www.drupal.org/files/issues/2018-04-17/2254935-45.patch | git apply -v
  3. Applies cleanly.
  4. Creating another article.
  5. drush cr
  6. Deleting via node tab: does not work - I still get sent to a page.
  7. Editing the article, then choosing delete: success, I receive a modal (screenshot below).
  8. Trying this on /admin/content for good measure: does not work - I still get sent to a page..

Looks like this ticket is explicitly for the content entity form screen, so marking this as RTBC because it meets the expectations of the issue title. But, I do wonder if this modal should be available for node (or even more entities) deletes in all contexts.

runeasgar’s picture

Issue summary: View changes
StatusFileSize
new55.19 KB

Forgot the screenshot:

manuel garcia’s picture

Thank you @runeasgar!

You are correct, this issue's scope is only about the delete link on the entity edit forms.

andrewmacpherson’s picture

Just noticed this issue and #2253257: Use a modal for entity delete operation links are both RTBC.

Some manual aaccessibility testing will be a good idea here, to avoid a serious regression. We're using an existing pattern so hopefully it'll be fine, but I'd like to check everything is wired up correctly here, labels make sense, etc.

yoroy’s picture

Status: Reviewed & tested by the community » Needs work

Finally got to test this manually again. It's not really a useful change if we introduce two ways this confirmation pattern works. I think we should include the tab (on entity display and dropbutton links (in listings) to do the same. This is a super useful and userfriendly change but we should make this the new default then for all ways you can delete entities. Sorry for not making that call earlier.

manuel garcia’s picture

Title: Use a modal for content entity form delete link » Use a modal for content entity form delete confirmation forms
Issue summary: View changes

Yeah you're right @yoroy - let's just expand the scope of this then.

Updating the issue summary and title accordingly.

manuel garcia’s picture

Title: Use a modal for content entity form delete confirmation forms » Use a modal for content entity delete confirmation forms
manuel garcia’s picture

Title: Use a modal for content entity delete confirmation forms » Use a modal for content entity form delete links confirmation forms

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

manuel garcia’s picture

Issue summary: View changes
Issue tags: -JavaScript +JavaScript

Re #50 - the entity operation delete links (ie on admin/content) are being tackled here #2253257: Use a modal for entity delete operation links

Updating the Issue summary to clarify the scope and remaining tasks.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

hooroomoo’s picture

StatusFileSize
new3.76 KB
pooja saraah’s picture

StatusFileSize
new3.78 KB
new969 bytes

Fixed failed commands on #64
Attached patch against Drupal 10.1.x

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new4.69 KB
new932 bytes

Changed the operations list to use modal for delete confirmation.

While I did that, I noticed similar issues that @bnjmnm reported on #2880003: Use modals on the Manage Fields page where the focus moved to the window when returning from dialog because the button from toolbar is no longer focusable.

Status: Needs review » Needs work

The last submitted patch, 66: 2254935-66.patch, failed testing. View results

tim.plunkett’s picture

Issue tags: +Field UX
hooroomoo’s picture

StatusFileSize
new7.92 KB

Fixed failed tests from #66

hooroomoo’s picture

StatusFileSize
new7.52 KB
hooroomoo’s picture

Status: Needs work » Needs review
smustgrave’s picture

Agree this needs accessibility review as it provides a new popup functionality.

Tested #70
When the modal opens the focus goes to the "Delete" button - which is good
Tabbing does not leave the module. "Delete" button -> "Cancel" button -> X button in the corner - while is good

This is the markup of the modal

<div tabindex="-1" role="dialog" class="ui-dialog ui-corner-all ui-widget ui-widget-content ui-front ui-dialog-buttons" aria-describedby="drupal-modal" aria-labelledby="ui-id-1" 

role = dialog seems correct
aria-describedby and aria-labelledby are the ones I'm not 100% about.

Think accessibility

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new85 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mgifford’s picture

tim.plunkett’s picture

Status: Needs work » Closed (duplicate)
Issue tags: -Needs accessibility review

This issue is confusingly similar to #2253257: Use a modal for entity delete operation links. While this is intended for content entities and the other for config entities, there is not currently a split implementation between the two. Both content and config entities rely on \Drupal\Core\Entity\EntityForm, and the code changes on the two issues are almost identical. The only difference is test coverage.

Since this is the "newer" issue and the other one has a more recently updated MR, I'm going to mark this as a duplicate. I will transfer contribution credit over to the other issue.

aaronmchale’s picture

Thanks @tim.plunkett

From both a code maintainability and usability perspective, the more consistency we have across the admin UI the better.

tim.plunkett’s picture

Issue tags: -Field UX