riophae / vue-treeselect

A multi-select component with nested options support for Vue.js
https://vue-treeselect.js.org/
MIT License
2.91k stars 509 forks source link

Close menu #511

Open roma177 opened 2 years ago

roma177 commented 2 years ago

Hello. Currently menu closes only when it looses blur as I could see calling instance.closeMenu() method. I want itself close menu when I want. How I can do that (probably with events?)

TitanFighter commented 2 years ago

Use alwaysOpen param. Here is the example: https://vue-treeselect.js.org/#more-features

roma177 commented 2 years ago

That is not exactly what I asked about. alwaysOpen just opens <VueTreeselect-MenuPortal> component. I need to close <VueTreeselect-MenuPortal> component if it is open by clicking at <VueTreeselect-Control> component itself. There should be some method which closes menu when you click outside of VueTreeselect. I want to know how can I call it.

TitanFighter commented 2 years ago

I want itself close menu when I want

set alwaysOpen=false when you want. This is a hack. There is no direct approach.

Dual-Ice commented 5 months ago

You can use openMenu() or closeMenu() like this this.$refs['treeselect'].closeMenu()