Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG] clicking anywhere on the page scrolls to the top when a dropdown is open #2485

@lovasoa

Description

@lovasoa

Browser

all

OS

all

Screen size

all

Describe the bug

When a dropdown is present and has data-bs-auto-close="outside", then clicking outside while the dropdown is open scrolls back to the dropdown. This is particularly problematic when the dropdown items themselves are anchor links to other parts of the same page.

How to reproduce

Here is a minimal reproduction (see the attached codepen)

<ul class="navbar-nav ms-auto">
  <li class="nav-item dropdown">
    <a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" data-bs-auto-close="outside" role="button">Click here</a>
    <div class="dropdown-menu dropdown-menu-start" data-bs-popper="static">
      <a class="dropdown-item" href="#destination">Then here</a>
    </div>
  </li>
</ul>

<div id="destination" style="margin-top: 1000px">
  <p>Now click here (should do nothing, but scrolls to the top)</p>
</div>

The page

Screenshots

Screencast.From.2025-09-09.15-36-21.mp4

The following illustrates a similar issue on the official documentation page for dropdowns

Screencast.From.2025-09-09.15-32-34.mp4

JSFiddle

https://codepen.io/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-/pen/raObLBV

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions