Problem/Motivation

In reviewing #2994702: Allow editors to alter embed-specific metadata, as well as `data-align` and `data-caption`, the UX team had this feedback about the "remove" button that appears for each embedded media item:

...it [is] entirely too easy to accidentally stray-click the "X" icon and remove an embed. They asked for a confirmation dialog to be displayed first. Since the existing image embed button does not display an "X" (you just have to click the embedded image and press Delete on your keyboard), we agreed to remove the "X" button from this patch and add it back, with a confirmation alert box, in a follow-up.

That's this follow-up.

Embedded media with a remove button

Proposed resolution

Restore and update the relevant code from #2994702-43: Allow editors to alter embed-specific metadata, as well as `data-align` and `data-caption` into a new patch in this issue, and add a confirmation dialog when the "remove" button is clicked. (Also, figure out if the presence of the confirmation should be configurable.)

Remaining tasks

Restore the old code, then determine what the text of the confirmation box should be, whether it should be configurable, etc. Then add tests, get UX and accessibility sign-off, and commit.

User interface changes

Media items embedded in a CKEditor instance will receive a new button which allows them to be removed from the content.

API changes

None expected.

Data model changes

None.

Release notes snippet

TBD

CommentFileSizeAuthor
#50 3074859-50.patch8.43 KBwilfred.waltman
#49 3074859-49-10.1.patch8.44 KBseanb
#47 3074859-nr-bot.txt92 bytesneeds-review-queue-bot
#46 3074859-40-reroll.patch33.33 KBseanb
#42 3074859-42.patch33.15 KB_utsavsharma
#42 interdiff_40-42.txt1.84 KB_utsavsharma
#40 3074859-40.patch33.33 KBricovandevin
#36 interdiff_33-36.txt683 bytesravi.shankar
#36 3074859-36.patch32.47 KBravi.shankar
#35 3074859--after--patch--pic.png170.73 KBvikashsoni
#35 3074859--before--patch--pic.png166.63 KBvikashsoni
#33 3074859-33.patch32.44 KBseanb
#31 3074859-31-screenshot.png61.71 KBvsujeetkumar
#29 interdiff_28-29.txt11.89 KBvsujeetkumar
#29 3074859-29.patch32.42 KBvsujeetkumar
#28 interdiff_26-28.txt1.16 KBravi.shankar
#28 3074859-28.patch24.99 KBravi.shankar
#27 Applied Patch 3074859.png1.22 MBchetanbharambe
#27 After Patch 3074859.png486.8 KBchetanbharambe
#27 Before Patch 3074859.png468.54 KBchetanbharambe
#26 3074859-26.patch24.93 KBkapilv
#24 3074859_20.patch32.61 KBnishantghetiya
#19 interdiff_15-19.txt3.21 KBvsujeetkumar
#19 3074859_19.patch32.38 KBvsujeetkumar
#15 3074859-15--do-not-test.patch10.73 KBvsujeetkumar
#15 3074859-15--combined-w-078287-61--and--3071713-37.patch28.65 KBvsujeetkumar
#8 3074859-8--combined-w-078287-61--and--3071713-37.patch45.75 KBoknate
#8 3074859-8--do-not-test.patch10.72 KBoknate
#8 sweet-relief-video-can-be-deleted.mov1.83 MBoknate
#7 how-do-I-delete-this-youtube-video.mov12.65 MBoknate
#6 cat-bat-with-remove-button.png381.19 KBoknate
#6 3074859-6.patch9.97 KBoknate

Comments

phenaproxima created an issue. See original summary.

seanb’s picture

entirely too easy to accidentally stray-click the "X" icon and remove an embed. They asked for a confirmation dialog to be displayed first.

We don't do that for media items selected in the entity reference widget. So not sure if it is any more "dangerous" or easy. In the current situation, you would have to click to move the cursor after the image (or use the arrow key until you get there) and then use the backspace. Which could be a pain if you have to delete a bunch of images in an article. That one-click shortcut is a great improvement imho.

I also think there is value in being consistent in the way media is presented and managed across different fields/widgets. Even if that means providing an extra way of doing things. Some people may like to click, others like to use the backspace. That shouldn't be a problem. If we are afraid users might click it when they don't want to, we could improve the size of the buttons for example?

oknate’s picture

I agree that the confirmation message seems unnecessary. The delete button that we had for a bit and then removed in #2994702: Allow editors to alter embed-specific metadata, as well as `data-align` and `data-caption` had "undo" integration, so you could easily hit the back button (or the CKEditor "Undo" button) if you accidentally deleted the embed with the button. Which I think is better UX than requiring the user to always confirm the deletion. Since there's an easy way to undo it, a confirmation step seems superfluous.

wim leers’s picture

We don't do that for media items selected in the entity reference widget. So not sure if it is any more "dangerous" or easy. In the current situation, you would have to click to move the cursor after the image (or use the arrow key until you get there) and then use the backspace. Which could be a pain if you have to delete a bunch of images in an article. That one-click shortcut is a great improvement imho.

+1

I also think there is value in being consistent in the way media is presented and managed across different fields/widgets.

+1

so you could easily hit the back button (or the CKEditor "Undo" button)

Or CMD/CTRL+Z.

+1 for no confirmation.

wim leers’s picture

oknate’s picture

Issue summary: View changes
StatusFileSize
new9.97 KB
new381.19 KB

Here's an initial patch to restore the remove button. No confirmation dialog yet.

oknate’s picture

Priority: Normal » Major
StatusFileSize
new12.65 MB

It's impossible to delete YouTube videos. Hopefully this issue will help.

This is more important now, as I found this UX bug with embedded youtube videos, using the default Remove Video media type.

Right now, to delete embedded media in the WYSIWYG, you do the following:
1) Click on the embedded media.
2) Hit the delete key.

But with YouTube videos, when you click on it, it starts or stops playing, or opens a page on YouTube's website. So you can't select your embedded media.

Video:
https://www.drupal.org/files/issues/2019-10-03/how-do-I-delete-this-yout...

oknate’s picture

Title: Add a button to remove an embedded media item from the editor » [PP-1] Add a button to remove an embedded media item from the editor
Status: Active » Needs review
StatusFileSize
new1.83 MB
new10.72 KB
new45.75 KB

Postponing on #3071713: Make error messages for embedded media themeable
It moves the JavaScript theme functions to a new file. Plus it's RTBC, so it should land soon.

I confirmed that with patch #6 (rerolled on top of 3078287-61 and 3071713-37), you can delete the Remote Video with either the mouse or by tabbing to the delete button and hitting enter/space.

Video:
https://www.drupal.org/files/issues/2019-10-03/sweet-relief-video-can-be...

wim leers’s picture

But with YouTube videos, when you click on it, it starts or stops playing, or opens a page on YouTube's website. So you can't select your embedded media.

You can:

  • Still click it if it's aligned.
  • Give it focus by using the arrow keys

Furthermore, this is where #3064572: Add mask to prevent interaction with embedded media comes in (which still needs a sibling core issue, or perhaps we can change that to be the core issue). That is blocked on #3072382: Update CKEditor to version 4.13.

wim leers’s picture

Priority: Major » Normal

Per #9, demoting. The ability to interact with embedded media is the real problem here. And that is blocked on CKEditor 4.13.

Status: Needs review » Needs work

The last submitted patch, 8: 3074859-8--combined-w-078287-61--and--3071713-37.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

wim leers’s picture

Title: [PP-1] Add a button to remove an embedded media item from the editor » Add a button to remove an embedded media item from the editor

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.

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.

vsujeetkumar’s picture

Rerolled(#8), patch created for 9.1.x, Please review.

vsujeetkumar’s picture

Status: Needs work » Needs review

The last submitted patch, 15: 3074859-15--combined-w-078287-61--and--3071713-37.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

phenaproxima’s picture

Status: Needs review » Needs work

Test is failing, so I think we need to correct that before it's ready for review. Sorry!

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new32.38 KB
new3.21 KB

Fixed more tests, Please review.

Status: Needs review » Needs work

The last submitted patch, 19: 3074859_19.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

phenaproxima’s picture

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.

nishantghetiya’s picture

StatusFileSize
new32.61 KB

Re-roll this patch for 9.3.x

kapilv’s picture

Status: Needs work » Needs review
kapilv’s picture

StatusFileSize
new24.93 KB
chetanbharambe’s picture

Status: Needs review » Needs work
StatusFileSize
new468.54 KB
new486.8 KB
new1.22 MB

Verified and tested patch #26.
Patch applied successfully but functionality not working

Testing Steps:
# Apply Seven theme
# Goto: node/add/article
# Click on the image icon in the body field
# Upload the image
# User is not able to see edit icon and cross button

Expected Results:
# User should see edit icon and cross button on the image

Actual Results:
# User is not able to see edit icon and cross button

Not working as expected.
Moving to Needs Work.

ravi.shankar’s picture

StatusFileSize
new24.99 KB
new1.16 KB

Fixing custom command fails of patch #26.

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new32.42 KB
new11.89 KB

Fixing cs issues, Also added "filter.align.css" file, It was missed in last patch.

Status: Needs review » Needs work

The last submitted patch, 29: 3074859-29.patch, failed testing. View results

vsujeetkumar’s picture

StatusFileSize
new61.71 KB

@chetanbharambe According to my information It is "Media Image" field, In #27 you are test with normal image filed, I have checked and found both the buttons (Edit Media, Remove Media). Please have a look.

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.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new32.44 KB

Rerolled #29 for 9.3.x

Status: Needs review » Needs work

The last submitted patch, 33: 3074859-33.patch, failed testing. View results

vikashsoni’s picture

StatusFileSize
new166.63 KB
new170.73 KB

Applied #33 patch applied successfully
After patch button has been added in editor
Thanks for the patch
For ref sharing screenshot

ravi.shankar’s picture

Status: Needs work » Needs review
StatusFileSize
new32.47 KB
new683 bytes

Fixed failed tests of patch #33.

Status: Needs review » Needs work

The last submitted patch, 36: 3074859-36.patch, failed testing. View results

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.

ricovandevin’s picture

StatusFileSize
new33.33 KB

(Attempted to) reroll against 9.5.x.

ricovandevin’s picture

Status: Needs work » Needs review
_utsavsharma’s picture

StatusFileSize
new1.84 KB
new33.15 KB

Fixed CCF for #40.

Status: Needs review » Needs work

The last submitted patch, 42: 3074859-42.patch, failed testing. View results

seanb’s picture

When using the contrib ckeditor module you probably need #3340516: Add a button to remove an embedded media item from the editor.

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new33.33 KB

Here is a reroll for 9.5.10.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new92 bytes

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

This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

yoroy’s picture

I think this does not implement a confirmation dialog? Which is fine, it's not deleting but removing so recoverable. Would be good to update the issue summary to reflect this.

seanb’s picture

StatusFileSize
new8.44 KB

Attached patch works for Drupal 10.1 and the CkEditor 4 contrib module. It also needs the patch in #4 in #3340516: Add a button to remove an embedded media item from the editor.

wilfred.waltman’s picture

StatusFileSize
new8.43 KB

Reroll of #49 for Drupal 10.2

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.