Problem/Motivation

With the the fix in #2831409: Remove Confirm Deletion / restore actions for paragraphs it is now very easy and quick to remove a paragraph which is generally a good thing and much preferred to the previous behaviour. However since in some cases a user might accidentally remove a paragraph and loose a lot of her work, I suggest that we look into a solution that has a JS confirmation state with a small footprint.

Proposed resolution

After clicking the delete button show a little overlay in place with two buttons, one to confirm deletion and one to cancel the deletion. We need to see if we can implement this in a way that one can delete the paragraph with two consecutive clicks without moving the mouse too much, but also prevent a double-click that would skip the confirmation entirely.

A wireframe that was created during UX reviews for the thunder distribution (see related issue):

Screenshots of the current implementation:
Screenshot
Screenshot

Remaining tasks

  • Create a patch as a proof of concept and to be able to review that
  • Create JS tests to make sure this is working as expected

User interface changes

API changes

Data model changes

Issue fork paragraphs-2833934

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pixelmord created an issue. See original summary.

miro_dietiker’s picture

Great to see this posted as a follow-up.

Just a quick note:
There are already two layers to revert a remove.
- Just cancel the edit process. A remove is not saved. It's just an intermediate state.
- Use the revisions to revert. Paragraphs is nicely integrated.

But yeah, if this confirmation is lightweight and client side, i'm supporting this double click.
Adding this to our Trello boards / roadmap.

gpap’s picture

[deleted]

sarathkm’s picture

This should be optional and should have a checkbox at form widget settings.

yseki’s picture

Here is a patch that creates a client site confirmation button for the new experimental Paragraphs widget.
It's based on https://github.com/thunder/paragraphs_features/pull/12/files

Berdir’s picture

Status: Active » Needs review
Berdir’s picture

Issue tags: +Needs tests
Berdir’s picture

Screenshots would be helpful.

I'm even considering to go a step further. We could have a hidden checkbox "Delete", and the client-side code should just check that and visually hide the paragraph, then we could skip an extra ajax roundtrip and only process it the time it is submitted, for adding another paragraph, saving or some other action.

Status: Needs review » Needs work
miro_dietiker’s picture

Yeah...

The current ajax states also have ugly side effects like this: https://www.drupal.org/project/paragraphs/issues/2956843

Just cover removes client side until you save is much better.

For me the current pain point of working with content and removal is the slowness of the remove button.
If you need to remove multiple Paragraphs, you end up click + wait for multiple times.
If you experiment with content, it can easily happen that you need to delete 4..10 Paragraphs at some point.
(And sometimes if you click too early the form state breaks and you need to start over again...)

An "undo deletes" could be placed on the most top "..." button, resetting all client side delete states.
I do not really like to keep a row reserved for "deleted" Paragraphs like we had before.

What do you think?

miro_dietiker’s picture

Title: Introduce a client side confirmation for paragraph removal » Introduce client side remove, with confirmation? and undo
Priority: Normal » Major

As improving speed of editing is a current priority, i'm promoting.

AaronBauman’s picture

Can someone please update the summary to explain what is the feature request here, because i'm confused?
Looks like the "confirm removal" behavior was removed in #2831409: Remove Confirm Deletion / restore actions for paragraphs
But then, at some point - i haven't investigated to find out when - it was restored.

Is that a regression, or was it intentional?
If we can't agree on whether this feature should exist, can we at least wrap it with a toggle?

Lukas von Blarer’s picture

The patch in #5 works for me.

Adding screenshots to the IS.

saltwaterskin’s picture

In my case I needed to apply these changes because I am using a custom paragraphs widget based on the one provided by the paragraphs browser module. The widget does not appear to support the confirmation on removal functionality. I made a small adjustment to the patch in #5 to add a value="Remove" attribute to the remove button.

bradtreloar made their first commit to this issue’s fork.

Lukas von Blarer’s picture

The MR is using jQuery.once resulting in errors like this:

Uncaught TypeError: $(...).find(...).once is not a function

queenielow’s picture

Following on this thread

sourabhjain’s picture

Assigned: Unassigned » sourabhjain
sourabhjain’s picture

Assigned: sourabhjain » Unassigned
Status: Needs work » Needs review