Hi,

I created a modal in a render array using #theme => 'bootstrap_modal' and a toggler using an anchor link with data-toggle and data-target-attributes.

Whenever I want to toggle my modal, it takes two clicks - one to initialize via the Plugin function, and one to afterwards send the toggle command to the initialized modal. The modal initializing function disregards the modal_show setting from the theme settings page. Adding a line to check this setting and--if it's true--setting the method to 'toggle' fixes this issue.

Comments

kevineinarsson created an issue. See original summary.

kevineinarsson’s picture

Status: Active » Needs review
StatusFileSize
new311 bytes

Patch attached.

vunda’s picture

kevineinarsson’s picture

StatusFileSize
new914 bytes

It seems that the Bootstrap jQuery UI Modal Bridge (modal.jquery.ui.bridge.js) does toggle the modal if the property is set, but it isn't always loaded - only if the drupal.dialog library is loaded as far as I can tell.

Wouldn't it make sense to put this in the common modal.js? Updated patch attached.

markhalliwell’s picture

Status: Needs review » Needs work
  1. +++ b/js/modal.jquery.ui.bridge.js
    @@ -174,11 +174,6 @@
    -
    -            // If show is enabled and currently not shown, show it.
    -            if (this.options.show && !this.isShown) {
    -              this.show();
    -            }
    

    This shouldn't be removed. It's necessary in some special cases where some jQuery UI dialogs might already be "initialized" but aren't shown when they should be.

  2. +++ b/js/modal.js
    @@ -103,6 +103,7 @@
    +            if (data.options.show) method = 'toggle';
    

    This "looks" ok... but maybe it should also check if !data.options.jQueryUiBridge?

kevineinarsson’s picture

Status: Needs work » Needs review
StatusFileSize
new343 bytes

Thanks Mark, updated the patch.

Status: Needs review » Needs work

The last submitted patch, 6: bootstrap-modal_init_toggle-2966832-6.patch, failed testing. View results

kevineinarsson’s picture

Status: Needs work » Needs review

Build successful puts the issue to needs work? I'm confused.

markhalliwell’s picture

Status: Needs review » Closed (cannot reproduce)

I cannot reproduce this issue using https://getbootstrap.com/docs/3.3/javascript/#live-demo and the latest code.

kevineinarsson’s picture

Status: Closed (cannot reproduce) » Needs review
StatusFileSize
new947 bytes

Hi Mark!

The issue still exists in 8.x-3.x if the option jQuery UI Bridge is disabled under the theme settings, in which case the modal_show setting isn't being respected.

I attached a module to easily reproduce the issue.

1. Enable and use the Bootstrap theme
2. Set jQuery UI Bridge to false in the theme settings
3. Enable the foo module
4. Visit /foo

The modal won't toggle when the button is clicked, regardless if modal_show is true or false ('Shows the modal when initialized' in the modal theme settings). The patch in #6 checks if we're meant to toggle on init (data.options.show/modal_show) and that jQuery UI Bridge isn't enabled since it also handles toggling on init.

**Edit: For some reason the .tar.gz got renamed to .tar_.gz when uploaded to d.o., but it should still work... let me know if not

markhalliwell’s picture

Title: Modal does not toggle when initializing, disregarding theme setting. » Native Bootstrap modal does not show when initializing
Status: Needs review » Fixed
StatusFileSize
new7.04 KB

Ok, I was able to take a look at this is more depth. Sorry, this is indeed a legitimate bug.

Primarily because the functionality defined on the following line was removed:
https://github.com/twbs/bootstrap/blob/df08d95495cf3cd9278099dc91c630423...

Furthermore, I've discovered that the relatedTarget isn't actually passed as it should be.

  • markcarver committed 7103041 on 8.x-3.x
    Issue #2966832 by kevineinarsson, markcarver: Native Bootstrap modal...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.