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 component closes on click if dropdown-item is replaced #303

Closed
ruimgoncalves opened this issue Sep 6, 2017 · 3 comments
Closed

Comments

@ruimgoncalves
Copy link

Overview of the problem

Buefy version: 0.5.1
Vuejs version: 2.4.2
OS/Browser: Windows Chrome 60.0

Description

The dropdown component closes unexpectedly if a is clicked, but only if this element is created after the first time the dropdown is opened.

Steps to reproduce

<b-dropdown>
    <button class="button is-primary" slot="trigger">
        <span>Click me!</span>
        <b-icon icon="arrow_drop_down"></b-icon>
    </button>

   <b-dropdown-item class="" v-for="itemName in items" :key="itemName" custom>
     <p>{{itemName}}</p>
   </b-dropdown-item>
</b-dropdown>

1 - Create and populate the items array
2 - Open the dropdown and click on one of the prepopulated items, the dropdown does not close.
4 - Close de dropdown and add one item to the items array
5 - Again open the dropdown, click on the new created item, the dropdown will close

@Tirke
Copy link
Contributor

Tirke commented Sep 7, 2017

dropdown doesn't like when items or content can disappear try to avoid raw v-if or v-for.

I'm not saying that's not a bug, I think it is one and a very frequent one.
But there are many workarounds and you can design very complex and useful dropdowns by simply using the custom attribute on b-dropdown-item.

<b-dropdown-item  custom>
  <div v-for="itemName in items" :key="itemName">
    {{itemName}}
  </div>
</b-dropdown-item>

You can try that.

@ruimgoncalves
Copy link
Author

I see where you are going, but the problem remains, now it is narrowed because it only disappears if you click the itemName element.

I think, the problem is that the new created elements are not in the whitelist

@chasegiunta
Copy link
Contributor

I believe this is what I just encountered... Here's an example using the dropdown in the docs
sep-07-2017 23-51-22

@jtommy jtommy closed this as completed in 25468ce Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants