Skip to content

fix(compare): require configurationId - #7306

Merged
Haroenv merged 5 commits into
masterfrom
fix/compare-bar-configuration-id
Oct 20, 2026
Merged

Haroenv merged 5 commits into
masterfrom
fix/compare-bar-configuration-id

Conversation

@Haroenv

@Haroenv Haroenv commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • connectCompare throws The configurationId option is required. when it is created without a configurationId, and the option is typed as required. Every compare widget carries its own ID, so the shared-store ID and the click-time throw in compare() are removed.
  • compareBar (JS) and <CompareBar> (React) get the check from the connector, so they no longer have their own guards.
  • useCompare now takes required props. The React default-theme example passes the ID to its per-hit useCompare call.

Result

A missing configurationId fails when the widget is created or rendered, instead of inside the Compare button's click handler. Tests cover the connector usage error; the widget and React tests pass a configurationId.

🤖 Generated with Claude Code

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 9 complexity

Metric Results
Complexity 9

View in Codacy

TIP This summary will be updated as you push new changes.

@pkg-pr-new

pkg-pr-new Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
More templates

algoliasearch-helper

npm i https://pkg.pr.new/algolia/instantsearch/algoliasearch-helper@7306

instantsearch-ui-components

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch-ui-components@7306

instantsearch.css

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.css@7306

instantsearch.js

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.js@7306

react-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch@7306

react-instantsearch-core

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-core@7306

react-instantsearch-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-nextjs@7306

react-instantsearch-router-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-router-nextjs@7306

vue-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/vue-instantsearch@7306

commit: a910702

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Size Change: -154 B (-0.01%)

Total Size: 1.04 MB

📦 View Changed
Filename Size Change
packages/instantsearch.js/dist/instantsearch.development.js 335 kB -41 B (-0.01%)
packages/instantsearch.js/dist/instantsearch.production.min.js 152 kB -38 B (-0.02%)
packages/react-instantsearch-core/dist/umd/ReactInstantSearchCore.min.js 73.8 kB -40 B (-0.05%)
packages/react-instantsearch/dist/umd/ReactInstantSearch.min.js 126 kB -35 B (-0.03%)
ℹ️ View Unchanged
Filename Size Change
packages/algoliasearch-helper/dist/algoliasearch.helper.js 44.5 kB 0 B
packages/algoliasearch-helper/dist/algoliasearch.helper.min.js 14.1 kB -2 B (-0.01%)
packages/instantsearch.css/components/ai-mode-button.css 1.76 kB 0 B
packages/instantsearch.css/components/autocomplete-min.css 4.33 kB 0 B
packages/instantsearch.css/components/autocomplete.css 4.68 kB 0 B
packages/instantsearch.css/components/button.css 1.98 kB 0 B
packages/instantsearch.css/components/chat-min.css 7.46 kB 0 B
packages/instantsearch.css/components/chat.css 7.97 kB 0 B
packages/instantsearch.css/components/filter-suggestions.css 1.89 kB 0 B
packages/instantsearch.css/themes/algolia-min.css 11.9 kB 0 B
packages/instantsearch.css/themes/algolia.css 12.7 kB 0 B
packages/instantsearch.css/themes/nova-min.css 12 kB 0 B
packages/instantsearch.css/themes/nova.css 12.8 kB 0 B
packages/instantsearch.css/themes/reset-min.css 1.3 kB 0 B
packages/instantsearch.css/themes/reset.css 1.38 kB 0 B
packages/instantsearch.css/themes/satellite-min.css 12.8 kB 0 B
packages/instantsearch.css/themes/satellite.css 13.8 kB 0 B
packages/vue-instantsearch/vue2/cjs/index.js 19.9 kB 0 B
packages/vue-instantsearch/vue2/umd/index.js 74.3 kB -4 B (-0.01%)
packages/vue-instantsearch/vue3/cjs/index.js 20.6 kB 0 B
packages/vue-instantsearch/vue3/umd/index.js 74.7 kB -6 B (-0.01%)

compressed-size-action

Comment thread packages/instantsearch.js/src/widgets/compare-bar/compare-bar.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused validation changes have targeted test coverage and no identified blocking issues; tests were not executed.

No open issues 🎉

What changed in this PR

Moves missing configurationId errors to JavaScript CompareBar creation and React rendering, rather than button clicks, while preserving the connector guard for toggles-only setups.

Changes:

  • Adds early validation in both widgets.
  • Adds validation tests.
  • Updates all-widget test helpers to supply a configuration ID.
File Description
packages/​react-instantsearch/​src/​widgets/​CompareBar.tsx Validates the ID before calling the hook.
packages/​react-instantsearch/​src/​widgets/​__tests__/​CompareBar.test.tsx Tests the missing-ID render error.
packages/​react-instantsearch/​src/​widgets/​__tests__/​__utils__/​all-widgets.tsx Supplies an ID to CompareBar.
packages/​instantsearch.js/​src/​widgets/​compare-bar/​compare-bar.tsx Validates and forwards the ID.
packages/​instantsearch.js/​src/​widgets/​compare-bar/​__tests__/​compare-bar-test.ts Tests required options and valid creation.
packages/​instantsearch.js/​src/​widgets/​__tests__/​index.test.ts Supplies an ID during widget initialization.

Review effort: Balanced

@Haroenv Haroenv changed the title fix(compareBar): require configurationId when the widget is created fix(compare): require configurationId in the connector Oct 19, 2026
@Haroenv
Haroenv requested review from a team, afrencalg and shaejaz and removed request for a team October 19, 2026 15:58
@Haroenv
Haroenv marked this pull request as ready for review October 19, 2026 15:58
Haroenv and others added 2 commits October 19, 2026 17:58
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Haroenv
Haroenv enabled auto-merge (squash) October 19, 2026 15:58
Haroenv and others added 2 commits October 19, 2026 17:59
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Haroenv
Haroenv force-pushed the fix/compare-bar-configuration-id branch from 27988ae to 1cd9c3b Compare October 19, 2026 16:00
@Haroenv
Haroenv requested a balanced review from Copilot October 19, 2026 16:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Changing configuration during an active search can leave React submitting comparisons with the previous configuration ID.

1 open issue

Review effort: Balanced

Comment thread packages/instantsearch.js/src/connectors/compare/connectCompare.ts
Comment thread examples/react/default-theme/src/App.tsx Outdated
@Haroenv Haroenv changed the title fix(compare): require configurationId in the connector fix(compare): require configurationId Oct 19, 2026
Comment on lines +90 to +91
// `CompareBar` is not part of `SingleWidget` (see `NON_COMPONENTS`), but
// `getAllInstantSearchWidgets` still renders it and it requires an ID.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's the reason for it not being in the single widget list?

@Haroenv
Haroenv merged commit a0c910e into master Oct 20, 2026
19 checks passed
@Haroenv
Haroenv deleted the fix/compare-bar-configuration-id branch October 20, 2026 09:35
Haroenv added a commit that referenced this pull request Oct 20, 2026
* fix(compareBar): require configurationId when the widget is created

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* test(compareBar): pass configurationId in widgets index test

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(compare): require configurationId in the connector

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* docs(examples): read the compare selection from render state

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
afrencalg added a commit that referenced this pull request Oct 20, 2026
#7306 moved the check from `compare()` to widget creation; carry this
PR's one-sentence wording over to the new location. The option's JSDoc
and the docs link appended by `withUsage` already say where the ID
comes from.

Co-authored-by: Cursor <cursoragent@cursor.com>
afrencalg added a commit that referenced this pull request Oct 20, 2026
#7306 moved the check from `compare()` to widget creation; carry this
PR's one-sentence wording over to the new location. The option's JSDoc
and the docs link appended by `withUsage` already say where the ID
comes from.

Co-authored-by: Cursor <cursoragent@cursor.com>
Haroenv added a commit that referenced this pull request Oct 20, 2026
* fix(compare): clarify option validation messages

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(compare): shorten the `configurationId` usage message

#7306 moved the check from `compare()` to widget creation; carry this
PR's one-sentence wording over to the new location. The option's JSDoc
and the docs link appended by `withUsage` already say where the ID
comes from.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Andras F <andras.ferencz@algolia.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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