-
Notifications
You must be signed in to change notification settings - Fork 531
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
Allow ToggleWidgetValues to accept multiple values #2182
Comments
I will discuss about this feature with @bobylito but I'm pretty sure it's a good thing that we can add into the v2 without a breaking changes for older implementations 👍 |
@iam4x that's what I was hoping, thanks! |
Hi @timkelty how is the component supposed to figure out which value to select? Or will it add all the filters at once when |
@bobylito right - so in the array example, any one of those values would be considered "on". In the fn example, it would only be on if you returned |
So if I understand correctly you have different values that are "on" in a single attribute of the dataset, right? Wouldn't it be easier to have a single value? Can you elaborate on the use case maybe? |
@bobylito It would be simpler yes, and my use-case is actually kind of dumb...basically my indexer can run out of my database or directly from the request. If it populates from the database, certain values get "minimized", e.g. Anyway - while my use case isn't great, (because I could just hack into my indexing stuff and fix that), I thought it could be useful other ways. For example - Consider a "Has Images" toggle. To do this, you'd have to index a new However, if you accept a fn as I suggest, you could do something like (with
|
Ok I got the problem of heterogenous data for a single attribute. And that could happen when scrapping some website. I would argue that if you know how to map the different values to a single About the function syntax that you propose, what's the value? It is the value of the facet? How do you see it working? Could it based on regexp or rules? Would something like that make sense: search.addWidget(instantsearch.widgets.toggle({
container: '#cat-toggle',
attributeName: `imageDescription`,
on: (value) => {
return value.indexOf('cat') !== -1; // all values that have cats in it will be caught as `on` values
},
})); If so, the facet values are not likely to be exhaustive and they can change with the current search parameters which can make that feature a bit random, no? |
In your example, the value of ...So maybe a function doesn't make sense. Initially I was thinking an array, because it felt similar to how you would pass a FacetList to |
@bobylito @iam4x Been over a year…any progress here? This came up again for me…this time I have a similar but different use-case: I want a toggle widget for "Include discontinued products", so when If the
Unfortunately, the It seems silly that I could make this work if I changed the toggle to "Hide Discontinued Products" instead of "Show Discontinued Products". |
Hi! I'm having a similar problem but for a "favorites" system. Users of our applications can add hits in their favorites, and we would like to use the search.addWidget(instantsearch.widgets.toggle({
container: '#toggle',
attributeName: 'id',
on: [3, 39, 44], // user's favorites hits
})); I will try to send a PR as soon as possible. EDIT: PR opened at #4420 |
Should this issue be closed since #4420 has been merged, or we are waiting for a new release? |
ah yes, it didn't have |
I'll release this on Monday. |
Nice, thanks you! |
@Kocal It's available@4.6.0. Thank you for your contribution :) |
Do you want to request a feature or report a bug?
feature
Feature: What is your use case for such a feature?
I have an attribute I'd like to use a toggle widget for, but I'd like to have the "on" value be one of many options.
Feature: What is your proposed API entry? The new option to add? What is the behavior?
I'd like to use it like this:
An alternate implementation might allow you to pass a fn with an argument of the value of the specified attr, returning a bool:
What is the version you are using? Always use the latest one before opening a bug issue.
1.11.12/2.beta-5
The text was updated successfully, but these errors were encountered: