I was getting this same error with the navbar and they weren't opening or closing. After much head scratching found out that the popper.js file had not been included in the libraries.yml file when I created my subtheme. The bootstrap.bundle.min.js, I'm guessing includes popper.
So for anyone that is also having issues check that you have the below file structure in libraries.yml and are not missing the popper.min.js file:
global-styling:
version: VERSION
js:
js/popper.min.js: { weight: -49 }
js/bootstrap.min.js: { weight: -48 }
js/barrio.js: {}
js/custom.js: {}- ๐ณ๐ตNepal sandeshyadav Dhangadhi, Kailali
If you landed to this page due to issues with dropdowns in the navbar, here is the cause of the problem and possible solutions.
What is the causing the issue?
For the dropdown to work, bootstrap uses a third party library popperjs. In the
THEME.libraries.yml
file of `SASS Starter Kit`, this library is missing which is causing the issue.To fix it,
Usebootstrap.bundle.min.js
instead ofbootstrap.min.js
. Thebootstrap.bundle.min.js
file includes popperjs library and thus solves the issue. You can use a CDN link(//cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js
) in yourTHEME.libraries.yml
file.
As mentioned by @GazzaT in #3 ๐ฌ Why bootstrap is loaded from node module and not from libraries.yml like Barrio? (bug with the navbar) Needs review , addingjs/popper.min.js: { weight: -49 }
to theTHEME.libraries.yml
solves the issue.Make sure to keep the weight -49 or lesser because
popper.min.js
needs to loaded beforebootstrap.min.js
. From the bootstrap docs,If you decide to go with the separate scripts solution, Popper must come first (if you're using tooltips or popovers), and then our JavaScript plugins
.
I would prefer because it is a modular approach and lets us exclude it(popperjs) if not required.
- Status changed to Needs review
almost 2 years ago 12:58pm 2 May 2023 - ๐ฎ๐ณIndia ravi kant Jaipur
#3 solution is working for me. Creating patch for this solution.
- ๐บ๐ธUnited States tommyk
Thank you for posting this. Adding text strings for toolbar and admin_toolbar to help others find it. I spent many hours debugging before actually figuring out a related issue.
- Status changed to Closed: cannot reproduce
about 1 year ago 6:02am 5 April 2024 - ๐ฎ๐ณIndia ravi kant Jaipur
The solution according to the patch has already been applied on Branch 5.x latest release.