Dependencies of jQuery UI are being deprecated in core (*). When this happens, it may affect any site that depends on the jQuery UI Bridge feature of Bootstrap theme.

jQuery UI Bridge in Bootstrap is broken with Drupal 9.2.0 out, due to changes in the way the libraries in core are defined.

Is it possible to provide a version of Bootstrap theme that directly depends on jQuery libraries that are provided by contrib projects https://www.drupal.org/project/jquery_ui

(*) references:

Issue fork bootstrap-3219852

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

markus_petrux created an issue. See original summary.

markus_petrux’s picture

Issue summary: View changes
markus_petrux’s picture

Title: Dependencies of jQuery UI are being deprecated in core » Bootstrap dialogs with jQuery UI Bridge enabled are broken with Drupal 9.2.x
Category: Feature request » Bug report
Issue summary: View changes
markus_petrux’s picture

Well, I've been able to fix this from the subtheme, by removing the jquery.ui assets defined by core with the drupal.dialog libray in 9.2.x

/**
 * Implements hook_element_info_alter().
 *
 * Temporary bugfix for: Bootstrap dialogs with jQuery UI Bridge enabled are
 * broken with Drupal 9.2.x.
 *
 * @link https://www.drupal.org/project/bootstrap/issues/3219852
 */
function SUBTHEME_library_info_alter(array &$libraries, $extension) {
  if ($extension == 'core' && !empty($libraries['drupal.dialog'])) {
    if (!empty($libraries['drupal.dialog']['js'])) {
      foreach ($libraries['drupal.dialog']['js'] as $key => $asset) {
        if (preg_match('`^assets/vendor/jquery\.ui`', $key)) {
          unset($libraries['drupal.dialog']['js'][$key]);
        }
      }
    }
    if (isset($libraries['drupal.dialog']['css'])) {
      unset($libraries['drupal.dialog']['css']);
    }
  }
}

Maybe this could be done in \Drupal\bootstrap\Plugin\Alter\LibraryInfo::alter() with a patch here? ...though, in the end, something else will be needed when more changes are introduced in core as part of the core issue mentioned in the IS.

markus_petrux’s picture

Issue summary: View changes
markus_petrux’s picture

Nested modals in BS3 are not supported, but maybe... possible once the following core issue lands #2741877: Nested modals don't work: opening a modal from a modal closes the original ?

bsuttis’s picture

Thank you for posting the code above, I can confirm it restored the Bootstrap modals on my 9.2.0 project.

rmpereira’s picture

Same since the 9.2.0 Drupal version, I can confirm too that the code #4 works.

In addition, the issue/patch at the origin of the problem : https://www.drupal.org/project/drupal/issues/3113400

markus_petrux’s picture

Issue summary: View changes

Thanks for the pointer, added to IS.

pguillard’s picture

Issue summary: View changes
pjotr.savitski’s picture

I've been able to add the fix code directly into the bootstrap them hook, before the Bootstrap::alter. Shouldn't this code be included into the main theme code base for the 4.x release?

I did try to see if an Alter plugin could be used for that, but it seems that only bootstrap based themes are checked for providing those. I ended up adding a hook handler to the module itself. The code is mostly the same, with just a check to see if bootstrap is present, bootstrap based theme is active, modal handler setting is set to TRUE and jquery_ui_bridge setting is also set to TRUE.

/**
 * Implements hook_library_info_alter().
 *
 * Please see this issue for more details https://www.drupal.org/project/bootstrap/issues/3219852#comment-14140239
 */
function MODULE_library_info_alter(&$libraries, $extension)
{
  if (class_exists('\Drupal\bootstrap\Bootstrap')) {
    $theme = \Drupal\bootstrap\Bootstrap::getTheme();

    // Apply modal fixes to bootstrap based themes with modal enabled using jquery_ui_bridge
    if ($theme->isBootstrap() && $theme->getSetting('modal_enabled') && $theme->getSetting('modal_jquery_ui_bridge')) {
      if ($extension == 'core' && !empty($libraries['drupal.dialog'])) {
        // See the link above for the origin of this code
        if (!empty($libraries['drupal.dialog']['js'])) {
          foreach ($libraries['drupal.dialog']['js'] as $key => $asset) {
            if (preg_match('`^assets/vendor/jquery\.ui`', $key)) {
              unset($libraries['drupal.dialog']['js'][$key]);
            }
          }
        }
        if (isset($libraries['drupal.dialog']['css'])) {
          unset($libraries['drupal.dialog']['css']);
        }
      }
    }
  }
}
ericdsd’s picture

Thanks a lot Pjotr you saved me lot of time, #11 seems to work like a charm.

flocondetoile’s picture

snippet #11 did the trick

no74h’s picture

Thank you guys for providing the fix! I agree this should be included with bootstrap project.

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

jhedstrom’s picture

I added the logic from #11 to an MR. Also attaching a patch here for folks to use in composer.

Ivan616’s picture

I can confirm that patch from #11 resolved issues we had on a site after upgrading to Drupal 9.4.
We had server modals not opening trough bootstrap and now they all work again.

Thank you very much.

shelane’s picture

Status: Needs review » Closed (won't fix)

This theme will not be supported for Bootstrap 4. See alternative themes for this support.

dinazaur’s picture

Status: Closed (won't fix) » Active

It seems that you just closed the issue without even reading the context. Who even said something about Bootstrap 4?

shelane’s picture

The MR is set against the 4.x branch and not the 3.x branch.