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

feat(connectToggleRefinement): add support for array values #4420

Merged
merged 7 commits into from
Jun 4, 2020

Conversation

Kocal
Copy link
Contributor

@Kocal Kocal commented May 28, 2020

Hi 👋

This PR is a proposal for #2182 which add support for multiples values on on/off for the toggle refinement connector.

See #2182 for more information.

Result

It allow us to use the toggle refinement connector with multiple values:

connectToggleRefinement()({
  attribute: 'whatever',
  on: ['my', 'values'],
  off: ['something', 'else']
});

and the toggle refinement widget:

search.addWidget(instantsearch.widgets.toggleRefinement({
  container: '#toggle',
  attribute: 'whatever',
  on: ['my', 'values'],
  off: ['something', 'else']
}));

On the playground, I've used:

  toggleRefinement({
    container: '#toggle',
    attribute: 'brand',
    on: ['Sony', 'Incipio'],
  }),

and you can see it toggle both values.

What do you think?
Thanks!

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 28, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 444aa37:

Sandbox Source
InstantSearch.js Configuration

@Haroenv
Copy link
Contributor

Haroenv commented Jun 1, 2020

@Haroenv
Copy link
Contributor

Haroenv commented Jun 1, 2020

That's probably since they're on the same attribute, which isn't something we officially support I think. If the widgets are mounted in the other order, the result would be correct. I don't think we can really find a solution for that, except if toggle refinement doesn't remove other refinements in getWidgetSearchParameters

@eunjae-lee
Copy link
Contributor

You're right. I changed the order of the widgets, and the result is correct. Since it's a "toggle" refinement, I guess the current behavior probably makes sense. We can ship it and later get feedback.

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me this makes sense as a feature, and the code & tests look sound

@eunjae-lee eunjae-lee changed the title feat(connector:toggle-refinement): add support for array values feat(connectToggleRefinement): add support for array values Jun 4, 2020
Copy link
Contributor

@eunjae-lee eunjae-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. It looks good to me.

@eunjae-lee eunjae-lee merged commit fe1fbee into algolia:master Jun 4, 2020
@Kocal Kocal deleted the feat/GH-2182 branch June 4, 2020 15:58
@Kocal
Copy link
Contributor Author

Kocal commented Jun 4, 2020

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants