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 uses data-hs-combo-box-search-text value for selected input value instead of the option value #548

Open
antero111 opened this issue Jan 9, 2025 · 0 comments

Comments

@antero111
Copy link

Summary

data-hs-combo-box-search-text value is show in the HTML ComboBox input value when data is selected instead of the option value

Detailed Description

When selecting or highlighting a value with arrow keys from an HTML ComboBox, the data-hs-combo-box-search-text value is used to set the input value while the data for the selected option is received correctly from data-hs-combo-box-item-stored-data.

The issue is that the option label and the search-text can differ for example when one might want to add more search keywords for the search text to improve search results (or in my case add manual index number to not have the options be sorted alphabetically.)

Here is an example of the scenario where I ran into this problem: The selection uses an array of options that it assigns an index number to the start of the option and then the option element itself shows the value. When selected or highlighted, the input value is assigned the search-text value when I wanted the option value.

s0oxwVm7Hw

Another example can be seen in this basic example https://preline.co/docs/combobox.html#html-example for example when changing the Argentina label.

kuva

firefox_NsORaGyugG

And with search the issue can be seen here for example when I have a set keyword that I can find specifically and then select the option... the keyword is shown even thought it should not.

kuva

firefox_d6824G2auV


Originally my issue comes from the automatic sorting of the options to which I found a solution with the search-text index trick.

Automatic sorting can be problematic for example when having data that should be kept in certain order. I have data that is sorted by dates from back end and in front-end selection the data is sorted incorrectly due to the automatic sorting.

Is the automatic sorting needed or could it be a toggleable feature?


Oh, and also could the ComboBox documentation data options section be more explicit on each option to define whether its used with JSON data or with the HTML syntax. I have found myself looking at the source code fairly frequently while building my select components to know which is used with HTML that I use.


Preline v2.7 and Vue 3

Thank you for reading. Hope this issue is something to consider about.

Use Cases

User wants to define keywords to the data-hs-combo-box-search-text text without them showing in the options.

For example, I have a race track listing where each track (option) is grouped under a country and I would like to have an option for user to search the country and then the search-text matches all the country options and shows them. This is possible by adding the country to the option search-text but the option shown incorrectly.

In this example the search-text is like data-hs-combo-box-search-text="index country option" where the index and country can be seen when the option is selected. The correct behaviour should only show the "Ferritslev" in the input bar.

firefox_5YKOuKOTPR

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

1 participant