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

fix(queries): prevent network request #6205

Merged
merged 8 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
},
{
"path": "./packages/instantsearch.js/dist/instantsearch.production.min.js",
"maxSize": "80.5 kB"
"maxSize": "81.5 kB"
},
{
"path": "./packages/instantsearch.js/dist/instantsearch.development.js",
"maxSize": "190 kB"
},
{
"path": "packages/react-instantsearch-core/dist/umd/ReactInstantSearchCore.min.js",
"maxSize": "48.5 kB"
"maxSize": "49.5 kB"
},
{
"path": "packages/react-instantsearch/dist/umd/ReactInstantSearch.min.js",
"maxSize": "62 kB"
"maxSize": "62.5 kB"
},
{
"path": "packages/vue-instantsearch/vue2/umd/index.js",
Expand Down
14 changes: 11 additions & 3 deletions packages/instantsearch.js/src/lib/InstantSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ class InstantSearch<
public _createURL: CreateURL<TUiState>;
public _searchFunction?: InstantSearchOptions['searchFunction'];
public _mainHelperSearch?: AlgoliaSearchHelper['search'];
public _hasSearchWidget: boolean = false;
public _hasRecommendWidget: boolean = false;
public _insights: InstantSearchOptions['insights'];
public middleware: Array<{
creator: Middleware<TUiState>;
Expand Down Expand Up @@ -580,9 +582,15 @@ See documentation: ${createDocumentationLink({
// under the hood, we have a different implementation. It should be
// completely transparent for the rest of the codebase. Only this module
// is impacted.
return (
mainHelper.searchOnlyWithDerivedHelpers() && mainHelper.recommend()
);
if (this._hasSearchWidget) {
mainHelper.searchOnlyWithDerivedHelpers();
}

if (this._hasRecommendWidget) {
mainHelper.recommend();
}

return mainHelper;
};

if (this._searchFunction) {
Expand Down
Loading