diff --git a/packages/vue-instantsearch/src/components/Index.js b/packages/vue-instantsearch/src/components/Index.js index a9ef675a25c..ce46b69c31f 100644 --- a/packages/vue-instantsearch/src/components/Index.js +++ b/packages/vue-instantsearch/src/components/Index.js @@ -26,14 +26,23 @@ export default { }; }, props: { + // Not `required` because it's optional when `isolated` is `true`. The + // underlying index widget throws when neither `indexName` nor `isolated` + // is provided. indexName: { type: String, - required: true, + required: false, + default: undefined, }, indexId: { type: String, required: false, }, + isolated: { + type: Boolean, + required: false, + default: false, + }, }, render: renderCompat(function (h) { return h('div', {}, getDefaultSlot(this)); @@ -43,6 +52,7 @@ export default { return { indexName: this.indexName, indexId: this.indexId, + isolated: this.isolated, }; }, }, diff --git a/packages/vue-instantsearch/src/components/__tests__/Index.js b/packages/vue-instantsearch/src/components/__tests__/Index.js index 2da398f47d4..e7109476097 100644 --- a/packages/vue-instantsearch/src/components/__tests__/Index.js +++ b/packages/vue-instantsearch/src/components/__tests__/Index.js @@ -24,6 +24,21 @@ it('passes props to widgetParams', () => { expect(wrapper.vm.widgetParams).toEqual({ indexName: 'the name', indexId: 'the id', + isolated: false, + }); +}); + +it('passes the `isolated` prop to widgetParams without an `indexName`', () => { + const wrapper = mount(Index, { + propsData: { + isolated: true, + }, + }); + + expect(wrapper.vm.widgetParams).toEqual({ + indexName: undefined, + indexId: undefined, + isolated: true, }); });