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
- In the modal configuration, disable the "Show my height" option.
- Set a delay of 3 seconds for the modal to display.
- 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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | Screenshot -2024-11-08 15-03-10.png | 28.1 KB | joseft40 |
| #2 | Screenshot -2024-11-08 15-03-55.png | 55.55 KB | joseft40 |
| #2 | Screenshot -2024-11-08 15-04-21.png | 7.29 KB | joseft40 |
| modal-page-2841111-1.patch | 1.77 KB | joseft40 |
Comments
Comment #2
joseft40 commentedI have attached some screenshots.
Comment #3
renatog commentedThanks 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
Comment #4
joseft40 commentedHi @renatog
I have attached the patch:
modal-page-2841111-1.patch
Comment #5
renatog commentedAwesome! Really appreciated!
Let's test that
Thank you so much @joseft40