Problem/Motivation

The modal is not displayed correctly when using a custom theme.

When I disable the "Show my height" option and set a delay of 3 seconds for the modal display, an error message appears on my site:

Uncaught TypeError: Cannot read properties of undefined (reading 'bootstrap_version')

This error prevents the modal from functioning as expected within the custom theme.

Steps to reproduce

  1. In the modal configuration, disable the "Show my height" option.
  2. Set a delay of 3 seconds for the modal to display.
  3. Load the page with a custom theme and observe the console output.

Expected result: The modal should display correctly after the set delay without any errors.

Actual result: An error appears in the console: Uncaught TypeError: Cannot read properties of undefined (reading 'bootstrap_version').

Proposed resolution

To ensure that the required variables are available for the modal, I suggest moving the bootstrap_version and check_load_bootstrap_automatically variables into the hook_page_attachments. This change would ensure that these variables are consistently accessible within the modal-page library, regardless of theme configurations.

Environment

Drupal: 10.3.5
Modal Page: 5.1.0
PHP: 8.1.28
Database: MariaDB 10.4.33

Comments

joseft40 created an issue. See original summary.

joseft40’s picture

I have attached some screenshots.

renatog’s picture

Thanks for reporting @joseft40

The proposed solutions seems good

I'm busy in the last days but if you're able to provide a patch it'll be very useful

joseft40’s picture

Hi @renatog

I have attached the patch:
modal-page-2841111-1.patch

renatog’s picture

Status: Active » Needs review
Issue tags: +Needs manual testing

Awesome! Really appreciated!

Let's test that

Thank you so much @joseft40