Buefy: Feature request: Open/Close Dropdown Programmatically

Created on 30 Jun 2017  路  3Comments  路  Source: buefy/buefy

Description

I've got a use case where I need to close the Dropdown programmatically and a way to check if it is open.

Is this feature worthwhile and how could we implement it?

Most helpful comment

<b-dropdown ref="dropdown" @active-change="activeChanged">[...]</b-dropdown>

Check if it's active with the active-change event or by the isActive property.

Toggle with the toggle() method (available in v0.4.4) (that will be published in a few minutes):

this.$refs.dropdown.toggle()

Disable with the isActive = false property:

this.$refs.dropdown.isActive = false

All 3 comments

<b-dropdown ref="dropdown" @active-change="activeChanged">[...]</b-dropdown>

Check if it's active with the active-change event or by the isActive property.

Toggle with the toggle() method (available in v0.4.4) (that will be published in a few minutes):

this.$refs.dropdown.toggle()

Disable with the isActive = false property:

this.$refs.dropdown.isActive = false

Hello guys,

I am trying use toggle function like @rafaelpimpa exemplify, but something weird happens, the log display an error said toggle is not a function.

Uncaught TypeError: this.$refs.playitemDropdown.toggle is not a function

In that case 'playitemDropdown' is the ref of my b-dropdown element.

My env
Buefy version: 0.5.4;
Vue version: 2.5.13;

@rafaelpimpa Question on this fix: It seems like if the b-dropdown is "hoverable", then toggle (to programmatically close the menu) is ignored.

My use-case is this: I want my menu to me hoverable on desktop, but clickable on mobile. That's actually handled ok (it doesn't do a modal on mobile, but it allows me to click on it instead, which is great). However, on mobile, when a menu item is clicked, the menu doesn't close (and it does on desktop because I'm no longer hovering over it), even when we do an @click.native="closeMenu" and try to do so programmatically, like you've done above.

Thoughts on why it doesn't work?
https://codepen.io/anon/pen/mxxaXr?editors=1010

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itielshwartz picture itielshwartz  路  3Comments

daltonrooney picture daltonrooney  路  3Comments

abhinukala picture abhinukala  路  3Comments

teryngull picture teryngull  路  3Comments

evandroabukamel picture evandroabukamel  路  3Comments