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

Hide languages dropdown / set filter default to "All languages" #193

Closed
nicokaiser opened this issue Feb 3, 2024 · 6 comments
Closed

Hide languages dropdown / set filter default to "All languages" #193

nicokaiser opened this issue Feb 3, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@nicokaiser
Copy link
Contributor

nicokaiser commented Feb 3, 2024

Is there an elegant way to select "All languages" by default?
Currently the languages from the lang attribute in the root HTML element is used. However in some cases it might be desireable to ignore i18n and just select all languages by default (e.g. when the whole search-form-meta toolbar is not needed and can be hidden via CSS).

Would a filter_languages parameter make sense in this context? (Default true to maintain compatibility, but when set to false, search all languages and hide the dropdown)

@razonyang razonyang added the enhancement New feature or request label Feb 3, 2024
@nicokaiser
Copy link
Contributor Author

There seems to be an if-condition: if (params.langs.length < 2) { (in forms.ts), however since params.langs is an object (not an array), this will never be true.

When fixed to if (Object.keys(param.langs).length < 2) {, something else breaks, since the .search-filter-lang element is assumed to be there, and tried to add an event listener. Both can be fixed, but not I'm stuck, because without setting the language to "All" no results are found.

I'll try to understand how this module works and how it can be used on a single-language site without any language dropdowns, filters, etc.

@razonyang
Copy link
Member

razonyang commented Feb 3, 2024

Would a filter_languages parameter make sense in this context? (Default true to maintain compatibility, but when set to false, search all languages and hide the dropdown)

Make sense, but one parameter for two purposes is not a good way to go, since there is someone hope to hide the languages filter and search with current page language only. I'd like to add two parameters, one for the languages filter, one for the languages (all or current page language).

@nicokaiser
Copy link
Contributor Author

You are right. When there is only one language, this dropdown should be hidden anyway (see my above comment). When this is fixed (and results are found), this is totally fine.

I still need to figure out if I misconfigured something, since without setting the language to "All" every time, there are no search result at all. But this might as well be a configuration issue on my side.

@razonyang
Copy link
Member

When there is only one language, this dropdown should be hidden anyway (see my above comment)

I see, will check this use case later, let me know if you want to open a PR to fix it.

I still need to figure out if I misconfigured something, since without setting the language to "All" every time, there are no search result at all.

Do you have a public repo or live site to check this issue?

@razonyang
Copy link
Member

razonyang commented Feb 3, 2024

I've tested it myself on both of monolingual and multilingual sites, should be fixed since v0.8.5.

since without setting the language to "All" every time, there are no search result at all.

But I couldn't reproduce this, please share more details if you have any.

@nicokaiser
Copy link
Contributor Author

Great, thank you very much!
My issue with no results displaying was just a configuration issue on my side, so all is fine now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants