Comments (7)
Thanks @colinbes I managed to "remove" the item from the list by adding display: none;
to .vs__dropdown-option--selected
. Winner!
from vue-select.
For those looking as well - Spent time digging through code and found the class .vs__dropdown-option--selected added to items already selected.
from vue-select.
You're absolutely entitled to make that choice. That's why I suggested it could be optional.
I'm migrating a project to Vue.js and this option is absolutely mandatory for it. I figure it would be for others, like in the example you choose: nobody wants to have the same country selected twice, nor anyone I know would want selecting a country twice would remove it.
And I can't have my users to guess that re-selecting it will remove it – which, as I said, is totally counter-intuitive – because they're used to the contrary (as anybody else?).
And my users know that when they validate something, it will be saved to the database – whatever it is, but not the absence of it.
Keeping your props dry, in that regard, is killing a basic interaction everybody is used to.
from vue-select.
Would that approach work for you?
That would be a clean compromise. And I think I could always then manage a CSS rule that could hide it if I wanted to (or something). It's a better solution than hiding it completely. Very good thinking, thanks.
from vue-select.
I think hiding already selected items may be more confusing to users than leaving them in the list. This behaviour isn't implemented in Select2, so I don't think I'll be adding that one. I'd like to keep the list of props as short and succinct as possible.
from vue-select.
@gemp Just to be clear, I think you're totally right that clicking/return on an already selected item should just close the list, not unselect the option. I will implement that ASAP.
As far as hiding options from the dropdown that are currently selected, neither Select2 nor Chosen hide items from the list. With these two being the most popular out there, I don't think that hiding items is an interaction that people are used to. Select2 just displays them as active, and selecting it just closes the dropdown without changing the selection.
Chosen handles it a bit differently, by still displaying the list item, but providing UI clues that it's disabled. You can't select it using up/down arrows or with your mouse.
Would that approach work for you?
from vue-select.
Was this 'chosen' functionality ever included? I am also looking to either filter out already chosen option items (which I have working) or use 'chosen' class to indicate item already selected.
from vue-select.
Related Issues (20)
- Don't have scss directory when installed vue-select@beta version for vue3
- UMD build get's recognized as ESM by some bundlers such as esbuild/tsup
- Prenvent dropdown to be close when loading Ajax option with infinite scroll
- Clear not working with :multiple option
- vue-tsc newer than 1.8.19 breaks HOT 2
- Using v-select with Vue 3 inside modal HOT 4
- vue-select with tailwind css class for longer text the search input field goes to next line.
- click event not working on a button inside no-options slot HOT 1
- Vue 2 CodePen Template in README.md is broken
- ambiguous indirect export: VueSelect HOT 1
- @input event in Vue.js 3 HOT 1
- Vue Select doesn't work on Bootstrap Modal HOT 1
- Localization not possible for aria-label & title attributes
- How to use @change/@input for changing a local value HOT 1
- Input event not being emitted HOT 1
- I'm not able to change vs--disabled background styles HOT 3
- Bug: Entered search data persists in vue-select with 'required' and 'multiple' enabled
- appendToBody="true" and dir="rtl"
- bug(docs): Codepen for the scoped slot option is broken.
- bug(animation): The fade out animation does not work when the appendToBody option is set.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-select.