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

Hide item in dropdown #1803

Open
laporchen opened this issue May 20, 2024 · 1 comment
Open

Hide item in dropdown #1803

laporchen opened this issue May 20, 2024 · 1 comment
Labels
question Further information is requested

Comments

@laporchen
Copy link

laporchen commented May 20, 2024

Description

Description

I have a logic in my dropdown menu to hide certain item.
But I can't find a property in this component that can do this. And v-if and v-show do not solve the issue here.

Using v-if would make it rendered as a default item.
Wrapping the item in template with v-show would cause an empty item being shown.

The only solution I think of right now is to modify the items passed into the dropdown component.
I want to know if there's a way to do this without touching the items being passed in.

<UDropdown :items="items">
  <!-- item login would be rendered as 'Default items slot' if user is false` -->
  <template #login>
    <div
      v-if="!user"
    >
      Login
    </div>
  </template>
  <!-- item user would be an empty item if user is false -->
  <template #user>
    <div
      v-show="!user"
    >
      Login
    </div>
  </template>
  <template #item>
    Default items slot
  </template>
</UDropdown>
@laporchen laporchen added the question Further information is requested label May 20, 2024
@noook
Copy link
Collaborator

noook commented May 21, 2024

As of now I'm not aware of an option to not show an item. I think as you said, your best option would be to filter out those items through a computed property or assignment before passing the items to your dropdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants