Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a.dropdown-toggle should be button.dropdown-toggle #40995

Open
3 tasks done
fulldecent opened this issue Oct 29, 2024 · 0 comments
Open
3 tasks done

a.dropdown-toggle should be button.dropdown-toggle #40995

fulldecent opened this issue Oct 29, 2024 · 0 comments

Comments

@fulldecent
Copy link
Contributor

Prerequisites

Describe the issue

Current documentation recommends to use a dropdown toggle as:

<a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a>

But this requires the unsemantic href="#". In production, I consider that to be a broken link.

Instead a better semantic could be:

<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>

This means that we would only ever include href="#" to recommend that a designer will link to one specific page on their website. We will not use it to mean a literal href="#" that is published to the web.

Reduced test cases

<nav class="navbar navbar-expand-lg bg-body-tertiary">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <a class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </a>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item dropdown">
          <button class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Dropdown
          </button>
          <ul class="dropdown-menu">
            <li><a class="dropdown-item" href="#">Action</a></li>
            <li><a class="dropdown-item" href="#">Another action</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="#">Something else here</a></li>
          </ul>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" aria-disabled="true">Disabled</a>
        </li>
      </ul>
      <form class="d-flex" role="search">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
      </form>
    </div>
  </div>
</nav>

What operating system(s) are you seeing the problem on?

macOS

What browser(s) are you seeing the problem on?

Chrome

What version of Bootstrap are you using?

5.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To analyze
Development

No branches or pull requests

2 participants