Skip to content

feat(compare): add transformItems - #7309

Draft
Haroenv wants to merge 1 commit into
masterfrom
feat/compare-transform-items
Draft

Haroenv wants to merge 1 commit into
masterfrom
feat/compare-transform-items

Conversation

@Haroenv

@Haroenv Haroenv commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a transformItems option to the compare connector (and so to the compareBar widget, useCompare and <CompareBar>) to trim or reshape the selection, for example to drop long descriptions.

Result

  • transformItems?: TransformItems<CompareItem>, i.e. (items: CompareItem[], metadata: { results: SearchResults | undefined | null }) => CompareItem[], defaulting to identity.
  • It transforms the items exposed in the render state, and compare() sends the transformed items as selected_products, so what the bar shows is what the agent receives. The _-prefixed keys are still stripped from the payload after the transform.
  • The store keeps the raw items. isSelected, addItem, removeItem, canAddItems, canCompare and the minItems/maxItems limits work on the raw selection, so a transform must map items one to one (no adding or removing) and keep each objectID.
  • The transform is per widget: compare() applies the transform of the widget it is called from, normally the compareBar.
  • compareBar and <CompareBar>/useCompare already forward the connector params, so no wrapper changes were needed. There is no Vue flavor for compare, and there is no common connector suite for compare on master, so tests are connector-level plus a <CompareBar> test.

🤖 Generated with Claude Code

Transform the selection items exposed in the render state. compare() sends
the transformed items to the agent, so what the bar shows is what the agent
receives. The selection, counts and limits keep working on the raw items.

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

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 17 complexity

Metric Results
Complexity 17

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@7309

instantsearch-ui-components

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

instantsearch.css

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

instantsearch.js

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

react-instantsearch

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

react-instantsearch-core

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

react-instantsearch-nextjs

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

react-instantsearch-router-nextjs

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

vue-instantsearch

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

commit: 101e8af

@github-actions

Copy link
Copy Markdown

Size Change: +147 B (+0.01%)

Total Size: 1.04 MB

📦 View Changed
Filename Size Change
packages/instantsearch.js/dist/instantsearch.development.js 334 kB +63 B (+0.02%)
packages/instantsearch.js/dist/instantsearch.production.min.js 152 kB +33 B (+0.02%)
packages/react-instantsearch-core/dist/umd/ReactInstantSearchCore.min.js 73.8 kB +27 B (+0.04%)
packages/react-instantsearch/dist/umd/ReactInstantSearch.min.js 125 kB +24 B (+0.02%)
ℹ️ 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 +1 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.4 kB 0 B
packages/instantsearch.css/components/chat.css 7.91 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.6 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.7 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

This branch has not been deployed

No deployments
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.

1 participant