It appears that the Dropdown initialization may be set up on the incorrect element. In Bootstrap 5, it is recommended to initialize the dropdown on the button or toggle element as it controls the dropdown's functionality.
If the remaining dropdown structure resembles the following:
<div class="dropdown-menu p-4">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown button
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</div>
You might want to consider this approach:
const dropdown = new bootstrap.Dropdown(document.querySelector('.dropdown-toggle'), {
autoClose: true
});
dropdown.toggle();