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(helper): remove getRefinements, hasRefinements #6570

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Feb 18, 2025

These functions are an aggregate of multiple different functions that depend on the type of refinement you're using. It's better to use the getter for the right type of refinement.

These functions are also not used in InstantSearch, as current refinements and clear refinements "re-implement" most of its logic to match the refinement to the right widget.

BREAKING CHANGE: remove helper.hasRefinements (use helper.state.isXXXRefined instead)
BREAKING CHANGE: remove helper.getRefinements (read helper.state.XXXRefinement instead)
BREAKING CHANGE: remove helper.state.getRefinements (read helper.state.XXXRefinement instead)

bundle size impact: -0.5kb min gz on the helper

@Haroenv Haroenv added this to the instantsearch.js v5 milestone Feb 18, 2025
@Haroenv Haroenv requested review from a team, sarahdayan and shaejaz and removed request for a team February 18, 2025 14:40
Comment on lines 55 to 56
const hasRefinements =
window.search.renderState['instant_search'].clearRefinements?.canRefine;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

normally you can directly read the renderState, but in the layout of this example, the widgets are in standalone files, and we can't import search or it would be circular.

Could be interesting in the future if templates got access to InstantSearch instance or parent.

Copy link

codesandbox-ci bot commented Feb 18, 2025

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 b9e052f:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

@Haroenv Haroenv changed the title feat(helper): remove getRefinements, hasRefinement feat(helper): remove getRefinements, hasRefinements Feb 18, 2025
@Haroenv Haroenv force-pushed the next branch 2 times, most recently from b1b5e4f to 32f50ac Compare February 18, 2025 15:41
These functions are an aggregate of multiple different functions that depend on the type of refinement you're using. It's better to use the getter for the right type of refinement.

BREAKING CHANGE: remove helper.hasRefinements (use helper.state.isXXXRefined instead)
BREAKING CHANGE: remove helper.getRefinements (read helper.state.XXXRefinement instead)
BREAKING CHANGE: remove helper.state.getRefinements (read helper.state.XXXRefinement instead)
@Haroenv Haroenv force-pushed the feat/remove-has-get-refinements branch from d57df09 to b9e052f Compare February 19, 2025 12:04
@Haroenv Haroenv merged commit c989492 into next Feb 19, 2025
10 checks passed
@Haroenv Haroenv deleted the feat/remove-has-get-refinements branch February 19, 2025 15:04
Haroenv added a commit that referenced this pull request Feb 19, 2025
These functions are an aggregate of multiple different functions that depend on the type of refinement you're using. It's better to use the getter for the right type of refinement.

BREAKING CHANGE: remove helper.hasRefinements (use helper.state.isXXXRefined instead)
BREAKING CHANGE: remove helper.getRefinements (read helper.state.XXXRefinement instead)
BREAKING CHANGE: remove helper.state.getRefinements (read helper.state.XXXRefinement instead)
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.

2 participants