Problem/Motivation

Buttons detected in .form-actions are copied to the modal's footer region and the originals are hidden. When those are clicked, it clicks the real one it was cloned from in the form. Unfortunately, if there's an AJAX update, this clone binding gets broken (because it's a new button).

Examples:

When embedding an image with Entity Embed, and end up on the thumbnail options dialog, there are no submit buttons at the bottom of the dialog. Sometimes there is a hidden button that has focus.

When adding an image to an article or basic page via the body field wysiwyg editor, failing to enter alt-text means you can't save the image.

Steps to replicate

Set bootstrap as the admin theme. Then:
1. Go to /node/add/article
2. Click the image icon in the editor
3. Upload an image
4. DON'T add alt text, then click save.
5. View error saying alt text is required.
6. Add alt text, click save.
7. Nothing happens.

If you add alt text to begin with, it works fine.

Proposed resolution

Patch at #4 manually updates the "fake modal buttons" by copying elements to the footer.

However, This JS should probably hide any existing form action buttons, clone them and then inject those clones into the footer then proxy all events to the original form action element (like is now currently done in ./js/dropdown.js). This will ensure that this works with all contrib modules.

GIF showing manual test Before and After patch #4.

animated gif shows side-by-side manual test

Remaining tasks

* Issue summary update.
* Another review or 2?
* Tests?

Comments

kattekrab created an issue. See original summary.

markhalliwell’s picture

Version: 8.x-3.1 » 8.x-3.x-dev
Status: Active » Postponed (maintainer needs more info)

I'm honestly unsure this would be a Bootstrap specific issue (at this point). The base theme doesn't alter that form (specifically) and any issue would likely be on the back-end (with core). That being said, it appears that got fixed?

It could possibly be a modal/dialog issue... but that seems rather unlikely. Could try the patch here: #2826277: Rework/update dialog JavaScripts

markhalliwell’s picture

Title: Can't save an image via wysiwyg after adding alt text » Fake modal buttons in footer aren't being replaced during AJAX update
Component: User interface » Code
Priority: Normal » Major
Status: Postponed (maintainer needs more info) » Active
Related issues: +#2826277: Rework/update dialog JavaScripts

So... this is, in fact, a bug with this base theme. Has to do with the dialog/modal JS crap that needs work on.

Basically, what's happening is that any buttons detected in .form-actions are copied to the modal's footer region and the originals hidden.

When those are clicked, it clicks the real one it was cloned from in the form.

Unfortunately, if there's an AJAX update, this clone binding gets broken (because it's a new button).

I'll keep this issue open because it's a very specific problem.

milesw’s picture

Status: Active » Needs review
StatusFileSize
new805 bytes
new58.25 KB

Ran into this with Entity Embed. When you go to embed an image, and end up on the thumbnail options dialog, there are no submit buttons at the bottom of the dialog. Sometimes there is a hidden button that has focus. See attached screenshot.

The problem is that the method being used to update the buttons $dialog.modal('option', 'buttons', buttons); isn't doing anything.

Here is a patch that manually updates these "fake modal buttons" by copying elements to the footer.

kattekrab’s picture

StatusFileSize
new66.4 KB
new997.47 KB

Oh awesome. Thanks @milesw

I've just done a side by side manual test using simplytest.me - this patch works!

I'm not a dev, but have had a quick look at the code itself. It seems straightforward, no obvious problems, but I'm not qualified to say for sure. I do wonder though if we need tests for this?

Screengrab of the patch via dreditor, and a gif of manual test below. I'd say RTBC, but probably need a dev to actually review the code, and @markcarver to say whether this needs tests.

Screengrab of dreditor's code diff

edit: removed gif, added to IS.

markhalliwell’s picture

Status: Needs review » Needs work
Related issues: +#2838956: Events bound to original dropdown elements are lost

I'd much rather we not create arbitrary buttons.

This JS should probably hide any existing form action buttons, clone them and then inject those clones into the footer then proxy all events to the original form action element (like is now currently done in ./js/dropdown.js). This will ensure that this works with all contrib modules.

kattekrab’s picture

Issue summary: View changes
kattekrab’s picture

Issue summary: View changes

IS tidy

kattekrab’s picture

Issue summary: View changes
alx_benjamin’s picture

Status: Needs work » Needs review

Can this patch be deployed?

markhalliwell’s picture

Status: Needs review » Needs work

See #6.

markhalliwell’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2831237: Bootstrap modal does not work well with jQuery UI dialog
adrianavaz’s picture

StatusFileSize
new1.35 KB

This patch removes the fake modal buttons from modal-footer.

adrianavaz’s picture

StatusFileSize
new1.32 KB

This patch removes the fake modal buttons from modal-footer.

agolubic’s picture

StatusFileSize
new2.16 KB

Current patch is not working after bootstrap update to 3.16.0. New patch in attachment :)

markhalliwell’s picture

Clearly, something isn't working... but removing them entirely isn't really a proper "fix".

julienvey’s picture

StatusFileSize
new2.16 KB

New patch for bootstrap 3.23.0 :)

julienvey’s picture