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

Dropdown doesn't render when only 1 result is returned from live server source #55

Closed
AaronMLB opened this issue Jun 21, 2022 · 4 comments

Comments

@AaronMLB
Copy link

AaronMLB commented Jun 21, 2022

Hi,

I'm trying to use Tags as a user-friendly field for identifying a particular, single database record.

A simple example might be a private messaging system, which searches a database of usernames. If multiple results are returned, the dropdown menu with all valid suggestions renders correctly, but if only one is found it doesn't render at all - no .show is generated - and the containing .form-control.dropdown gets .is-invalid added.

<select multiple name="person" data-placeholder="Start typing"
                        id="suggestfield"
                        data-server="/user-suggest/"
                        data-live-server="1"
                        data-suggestions-threshold="3"
                        data-allow-clear="1"
                        data-full-width="1"
                        data-max="1">
                        <option disabled hidden value="">Choose a person</option>
                    </select>
import Tags from "/js/tags.js";
Tags.init("#suggestfield");

I've simplified a few values for explanation, but that is otherwise my code. Correctly formed JSON is returned, and no errors are reported in console; it simply seems to be not liking having only one single possible suggestion. I've updated whatever I may have been using to 1.4.34 with no change.

Post-thought: Could it be that the queried string is not necessarily within the returned suggestion text, as I am also searching an AKA table, but only returning the root text value?

@lekoala
Copy link
Owner

lekoala commented Jun 22, 2022

i've updated the demo with a single value result, it seems to work fine

but indeed, the list is filtered. if you want to show all server side suggestions, you need to use showAllSuggestions

@AaronMLB
Copy link
Author

Thanks @lekoala, but still no luck with that.

Query: joe

Returned JSON:
[{"value":17049,"label":"American Apologist"}]

(Imagine that 'American Apologist' is a user's nickname and their real name is 'Joe Smith', so matching correctly DB-side.)

Renders the same as before: no dropdown, just adding .is-invalid.

I've tried both data-show-all-suggestions="true" and data-show-all-suggestions="1" with no change.

@lekoala
Copy link
Owner

lekoala commented Jun 22, 2022

indeed! this should fix your issue
https://github.com/lekoala/bootstrap5-tags/releases/tag/1.4.35

@AaronMLB
Copy link
Author

Brilliant! Thanks so much @lekoala, that's sorted it right out. Wonderful. Thanks for your quick response and action!

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

2 participants