'Dropdown is not closed when clicked outside the button in Bootstrap 5

I have updated my site from BS4 to BS5.... all works, however, I have problems wth drop downs.

Please see this:

Well.... the drop down is opened when I click the button, but the only way to close it is by clicking inside the button again. If I click outside, dropdown is still opened.

Even when that should be the normal behaviour, I have explicitly added data-bs-auto-close="true" but no luck.

What is it going on here?

Note that this should be done automatically without adding some JS code. In BS4 it works correctly.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<div class="btn-group">
  <button id="btnFingerprints" type="button" class="btn btn-circle btn-secondary me-2 dropdown-toggle" data-bs-toggle-second="tooltip" data-bs-toggle="dropdown" aria-expanded="false" title="Testing">
      <i class="ti-exchange-vertical"></i>
  </button>

  <div class="dropdown-menu">
    <button class="dropdown-item" type="button" id="btnBajarHuellas">
        <i class="ti-download me-2"></i>Bajar huellas
    </button>
    
    <button class="dropdown-item" type="button" id="btnSubirHuellas">
        <i class="ti-upload me-2"></i>Subir huellas
    </button>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

<script>
let tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle-second="tooltip"]'))
tooltipTriggerList.map(function (tooltipTriggerEl) {
    return new bootstrap.Tooltip(tooltipTriggerEl)
})
</script>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source