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

Dark dropdowns/navbars don't get dark variables with dark theme #39984

Open
3 tasks done
karlshea opened this issue May 14, 2024 · 3 comments · May be fixed by #39989
Open
3 tasks done

Dark dropdowns/navbars don't get dark variables with dark theme #39984

karlshea opened this issue May 14, 2024 · 3 comments · May be fixed by #39989

Comments

@karlshea
Copy link

karlshea commented May 14, 2024

Prerequisites

Describe the issue

There are two separate but I think related issues:

  1. .navbar-dark is marked as deprecated in 5.3, and adding data-bs-theme="dark" to it enables dark color variables. However, setting it on a parent component does not enable those variables.
  2. .dropdown-menu-dark is marked as deprecated in 5.3 but data-bs-theme="dark" doesn't work at all.

Dark navbar code:

.navbar-dark,
.navbar[data-bs-theme="dark"] {
  ...
}

Dark dropdown code:

.dropdown-menu-dark  {
  ...
}

I think I would expect both to work like this:

.navbar-dark,
[data-bs-theme="dark"] .navbar,
.navbar[data-bs-theme="dark"] {
  ...
}

.dropdown-menu-dark,
[data-bs-theme="dark"] .dropdown-menu,
.dropdown-menu[data-bs-theme="dark"] {
  ...
}

Reduced test cases

Use the dark mode toggle on the documentation site, when in dark mode the dropdowns/navbars do not have the configured dark styles that appear when specifically setting navbar-dark or dropdown-menu-dark.

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?

v5.3.3

@julien-deramond
Copy link
Member

Thanks for reporting an issue @karlshea

It's not finalized yet, but #39291 might bring some useful information around these use cases:

What do you think?

@karlshea
Copy link
Author

I think this is still a bug, or at least the statement in the docs is misleading: "Instead of adding .dropdown-menu-dark, set data-bs-theme="dark" on the root element, a parent wrapper, or the component itself". That is not the case for either dropdowns or navbars (and possibly other "dark" variables).

And in fact for .dropdown-menu-dark the PR screenshots are actually exposing the bug, see the text "Please note that the rendering in this example is not exactly the same as the contextual dark mode version is darker than the dark variant." That's because the $dropdown-dark-x variables are no longer used without .dropdown-menu-dark.

To use one variable as an example: In _variables.scss there's $dropdown-dark-link-color. The only place that's used is _dropdown.scss in the class .dropdown-menu-dark. If .dropdown-menu-dark is deprecated and removed, that variable becomes useless because there's no [data-bs-theme="dark"] rule on .dropdown to use them.

Another example: _variables.scss $navbar-dark-active-color. That is used on a navbar without .navbar-dark and only [data-bs-theme="dark"], but is not used on a navbar where a parent element (or the html tag) has [data-bs-theme="dark"].

I think this could have slipped by since some of the colors are so similar, but if you set all of the $*-dark* variables to red it becomes a lot more clear when things are or are not working.

@AbhishekSharma55
Copy link

Hi there,

I want to contribute to this project and take on this issue as my first task. Could you please assign it to me? I am excited to work towards resolving it and will keep the team updated on my progress.

Thanks

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

Successfully merging a pull request may close this issue.

3 participants