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

Combobox values derived from options leads to edge cases #217

Closed
stefan-ernst opened this issue May 9, 2023 · 8 comments
Closed

Combobox values derived from options leads to edge cases #217

stefan-ernst opened this issue May 9, 2023 · 8 comments

Comments

@stefan-ernst
Copy link

Describe the bug

When trying to control combo box options and values externally, there can be edge cases because the selected options in "multiple" mode seem to be controlled by the available options. If you filter down the options, the values which are dependent on the options disappear from the combobox.

To Reproduce
Steps to reproduce the behavior:

  1. Create a combobox with multiple=true
  2. Add values via an array []
  3. Add options via an array ["one","two","three"]
  4. Add option "one" to values
  5. Filter the combobox options by searching the input field to "three"
  6. Selected option "one" should disappear

Expected behavior
Result filtering should have no impact on selected options

Screenshots
SCR-20230509-e4r
SCR-20230509-e56

Desktop (please complete the following information):

  • OS: MacOs
  • Browser Chrome
@fabien-ml
Copy link
Collaborator

Hi, thanks for reporting the issue.
Maybe its related to #189

@stefan-ernst
Copy link
Author

Hi, yes I think it goes a bit further than that as the selected option will then also replace the existing values array. If you want I can try to submit a PR for this, I think the values and option lists need to be separated. I'm not too familiar with solid yet but I can give it a try

@fabien-ml
Copy link
Collaborator

Yes, my problem is that both selected values and options are the same objects. I haven't found a solution to have a "copy" of the option when you select it so it will be independent of the combobox options.

@martinpengellyphillips
Copy link

Do you need to copy the option itself? In solid-select I use lists for the value and options so you can share the same object but still manage separately.

@fabien-ml
Copy link
Collaborator

Do you need to copy the option itself? In solid-select I use lists for the value and options so you can share the same object but still manage separately.

In solid-select the user provide all options and you filter internally, right ?

In Kobalte's Combobox it's the user responsibility to give a list of filtered options, so I don't have access to all.

@stefan-ernst
Copy link
Author

We could pass in the list of the selected values as well, or have that as an option when the multiple prop is set to true? Would not be as ergonomic but reduce the internal complexity

fabien-ml added a commit that referenced this issue Jul 14, 2023
@martinpengellyphillips
Copy link

In solid-select the user provide all options and you filter internally, right ?

No. In solid-select the options are reactive and so filtering happens outside. I just also provide a handy helper (createOptions) for that.

@fabien-ml
Copy link
Collaborator

Fixed in v0.10.0

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