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.

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
| Comment | File | Size | Author |
|---|---|---|---|
| #50 | 3074859-50.patch | 8.43 KB | wilfred.waltman |
| #49 | 3074859-49-10.1.patch | 8.44 KB | seanb |
| #47 | 3074859-nr-bot.txt | 92 bytes | needs-review-queue-bot |
| #46 | 3074859-40-reroll.patch | 33.33 KB | seanb |
| #42 | 3074859-42.patch | 33.15 KB | _utsavsharma |
Comments
Comment #2
seanbWe 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?
Comment #3
oknateI 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.
Comment #4
wim leers+1
+1
Or CMD/CTRL+Z.
+1 for no confirmation.
Comment #5
wim leersComment #6
oknateHere's an initial patch to restore the remove button. No confirmation dialog yet.
Comment #7
oknateIt'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...
Comment #8
oknatePostponing 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...
Comment #9
wim leersYou can:
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.
Comment #10
wim leersPer #9, demoting. The ability to interact with embedded media is the real problem here. And that is blocked on CKEditor 4.13.
Comment #12
wim leers#3071713: Make error messages for embedded media themeable landed so we can continue here.
Comment #15
vsujeetkumar commentedRerolled(#8), patch created for 9.1.x, Please review.
Comment #16
vsujeetkumar commentedComment #18
phenaproximaTest is failing, so I think we need to correct that before it's ready for review. Sorry!
Comment #19
vsujeetkumar commentedFixed more tests, Please review.
Comment #21
phenaproximaComment #24
nishantghetiya commentedRe-roll this patch for 9.3.x
Comment #25
kapilv commentedComment #26
kapilv commentedComment #27
chetanbharambe commentedVerified 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.
Comment #28
ravi.shankar commentedFixing custom command fails of patch #26.
Comment #29
vsujeetkumar commentedFixing cs issues, Also added "filter.align.css" file, It was missed in last patch.
Comment #31
vsujeetkumar commented@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.
Comment #33
seanbRerolled #29 for 9.3.x
Comment #35
vikashsoni commentedApplied #33 patch applied successfully
After patch button has been added in editor
Thanks for the patch
For ref sharing screenshot
Comment #36
ravi.shankar commentedFixed failed tests of patch #33.
Comment #40
ricovandevin commented(Attempted to) reroll against 9.5.x.
Comment #41
ricovandevin commentedComment #42
_utsavsharma commentedFixed CCF for #40.
Comment #44
seanbWhen using the contrib ckeditor module you probably need #3340516: Add a button to remove an embedded media item from the editor.
Comment #46
seanbHere is a reroll for 9.5.10.
Comment #47
needs-review-queue-bot commentedThe 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.
Comment #48
yoroy commentedI 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.
Comment #49
seanbAttached 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.
Comment #50
wilfred.waltman commentedReroll of #49 for Drupal 10.2