Skip to content

[Question] Add class to multiselect when noResult #1640

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

Open
bogdan0083 opened this issue Dec 26, 2022 · 3 comments
Open

[Question] Add class to multiselect when noResult #1640

bogdan0083 opened this issue Dec 26, 2022 · 3 comments

Comments

@bogdan0083
Copy link

Hey guys! Is it possible to add class to multiselect element when search found no results?

I want to hide dropdown completely when nothing is found. For this multiselect--no-result class would be super useful.

@akki-jat
Copy link
Collaborator

@bogdan0083 You have the visibility of options as you are passing the same to the vue-multiselect, so you can watch options array and when it is empty you can hide the dropdown or add the class.

@bogdan0083
Copy link
Author

bogdan0083 commented Jan 29, 2023

@bogdan0083 You have the visibility of options as you are passing the same to the vue-multiselect, so you can watch options array and when it is empty you can hide the dropdown or add the class.

@akki-jat I want to add class ONLY when I use search in multiselect with some query and search didn't find any results. I don't need to watch array of options. Let's say I have the following options:

USA
Mexico
Netherlands

And I type ASDFD in search field. The results will be empty obviously but how do I add class only when nothing is found on search? Can you give me an example please?

@akki-jat
Copy link
Collaborator

@bogdan0083 You can listen to @search-change listener (https://vue-multiselect.js.org/#sub-events) and do a query on you side and update the class by yourself.

For example - https://codesandbox.io/s/vue-multiselect-class-no-result-ulj3hn

But I see that it will be good to add the class on our side, so reopening the issue.

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

2 participants