Fix Popper.js Error When Adding Navbar Dropdown in Vartheme BS5

Created on 20 August 2024, 4 months ago
Updated 16 September 2024, 3 months ago

Problem/Motivation

When attempting to add a dropdown to the navbar in a Drupal site, a JavaScript error occurs, preventing the dropdown from functioning correctly. The error message indicates that the createPopper function from the Popper.js library is not recognized, leading to a TypeError.

Uncaught TypeError: Popper__namespace.createPopper is not a function
    at Dropdown._createPopper (dropdown.js?showaf:220:40)
    at Dropdown.show (dropdown.js?showaf:137:12)
    at Dropdown.toggle (dropdown.js?showaf:124:51)
    at HTMLButtonElement.<anonymous> (dropdown.js?showaf:390:40)
    at HTMLDocument.handler (event-handler.js?showaf:75:21)
The Responsive Theme Preview β†’ module is loading its Popper.js library

dropdown.js and tooltip.js are allocating the library by @popperjs/core

Not by it’s physical file location and name space.

@popperjs/core@2.9.2 is working but 2.11.8 is not

  • Add a dropdown menu to the navbar in your Drupal site.
  • Ensure that the dropdown.js file is included and that Popper.js is supposed to be loaded.
  • Attempt to toggle the dropdown menu by clicking on it.
  • Observe the JavaScript console for the error message mentioned above.

Proposed resolution

πŸ› Fix Popper.js Error When Adding Navbar Dropdown in Varbase Components Fixed

Add aBootstrap Fixer
Add custom Bootstrap fixes and changes over the default provided
Bootstrap 5.3.3 package.

Using UMD in Varbase Components and Vartheme BS5
The UMD format in Bootstrap is using ESM format.
`dropdown.js` and `tooltip.js` are allocating the library by `@popperjs/core`

  • Add Popper global namespace fixer for the `dropdown.js` file in Bootstrap.
  • Add Popper global namespace fixer for the `tooltip.js` file in Bootstrap.
  • Drop the Popper.js library file from the Responsive Theme preview module. Varbase Components and Vartheme BS5 are providing that using Node.js with Bootstrap 5.

Remaining tasks

  • βœ… File an issue about this project
  • βœ… Addition/Change/Update/Fix to this project
  • βœ… Testing to ensure no regression
  • βž– Automated unit/functional testing coverage
  • βž– Developer Documentation support on feature change/addition
  • βž– User Guide Documentation support on feature change/addition
  • βœ… UX/UI designer responsibilities
  • βœ… Accessibility and Readability
  • βœ… Code review from 1 Varbase core team member
  • βœ… Full testing and approval
  • βœ… Credit contributors
  • βœ… Review with the product owner
  • βœ… Update Release Notes and Update Helper on new feature change/addition
  • ❌ Release varbase-10.0.2, vartheme_bs5-3.0.3 β†’

Varbase update type

  • βœ… No Update
  • βž– Optional Update
  • βž– Forced Update
  • βž– Forced Update if Unchanged

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡―πŸ‡΄Jordan mohammedOdeh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024