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

dropdown-menu style when append-to-body #668

Open
rockisch opened this issue Dec 2, 2021 · 4 comments
Open

dropdown-menu style when append-to-body #668

rockisch opened this issue Dec 2, 2021 · 4 comments

Comments

@rockisch
Copy link

rockisch commented Dec 2, 2021

Is your feature request related to a problem? Please describe.
Whenever a dropdown has append-to-body set to true, there's no way to add 'local' styles to the dropdown menu using CSS, since you can't filter the parent class, and just using .dropdown-menu would result in changes in all dropdown instances.

Describe the solution you'd like
Easier solution would be to add a menu-class/dropdown-menu-class prop to the dropdown component.

Describe alternatives you've considered
If the dropdown slot allowed other elements besides templates, the issue would also be solved, but I think that would result in a lot of CSS being rewritten to allow that.

Also, I know I can always just do the styling by JS, but I think CSS is always preferred.

Additional context
Quick example:

<dropdown :append-to-body="true" class="dropdown-test">
  <btn type="primary" class="dropdown-toggle">Dropdown</btn>
  <template slot="dropdown">
    <li>Option</li>
  </template>
</dropdown>

<style>
.dropdown-test > .dropdown-menu {  // this would normally work, but since it's appended to the body, it won't
  color: red;
}
.dropdown-menu {                   // this will work, but it will also override other dropdown-menu styles.
  color: red;
}
</style>
@wxsms
Copy link
Member

wxsms commented Dec 2, 2021

body > .dropdown-menu {
 // ...
}

this will work as expected I guess? but dropdown-menu-class still sounds reasonable.

@rockisch
Copy link
Author

rockisch commented Dec 2, 2021

I use other dropdown components with append-to-body, so doing that would also end up overriding the styles of other dropdowns. If you're ok with the dropdown-menu-class idea I can try implementing it on the weekend.

@wxsms
Copy link
Member

wxsms commented Dec 3, 2021

It's totally fine. Note that if you're targeting Vue.js 2, please make PR to 1.x branch, otherwise dev branch.

@wxsms wxsms removed their assignment May 18, 2022
@mika76
Copy link

mika76 commented Aug 19, 2024

This is still an issue - a class property would be great since append-to-body only adds an <ul class="dropdown-menu"> to the body which you cannot specify - you can style if it's the only dropdown, but if you have multiple it will clash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants