diff --git a/docgen/src/guides/v3-migration.md b/docgen/src/guides/v3-migration.md index 28098b2f27..0c94009f41 100644 --- a/docgen/src/guides/v3-migration.md +++ b/docgen/src/guides/v3-migration.md @@ -1278,6 +1278,10 @@ We've moved the `label` into the `templates.labelText` template to make it consi ## Connectors +### connectBreadcrumb + +- The BreadcrumbItem `name` property is renamed to `label`. + ### connectRange #### Options diff --git a/src/components/Breadcrumb/Breadcrumb.js b/src/components/Breadcrumb/Breadcrumb.js index 0442e71f21..cc1705a6f1 100644 --- a/src/components/Breadcrumb/Breadcrumb.js +++ b/src/components/Breadcrumb/Breadcrumb.js @@ -10,7 +10,7 @@ const renderLink = ({ cssClasses, createURL, refine, templateProps }) => ( ) => { const isLast = idx === items.length - 1; const link = isLast ? ( - item.name + item.label ) : ( ( refine(item.value); }} > - {item.name} + {item.label} ); return (
  • { items: [ { value: 'val0', - name: 'name0', + label: 'label0', }, ], cssClasses: { @@ -75,11 +75,11 @@ describe('Breadcrumb', () => { items: [ { value: 'val0', - name: 'name0', + label: 'label0', }, { value: 'val1', - name: 'name1', + label: 'label1', }, ], cssClasses: { diff --git a/src/components/Breadcrumb/__tests__/__snapshots__/Breadcrumb-test.js.snap b/src/components/Breadcrumb/__tests__/__snapshots__/Breadcrumb-test.js.snap index 3ff729e788..80c8c58052 100644 --- a/src/components/Breadcrumb/__tests__/__snapshots__/Breadcrumb-test.js.snap +++ b/src/components/Breadcrumb/__tests__/__snapshots__/Breadcrumb-test.js.snap @@ -46,7 +46,7 @@ exports[`Breadcrumb should render with a single item 1`] = `
  • with a single item 1`] = ` } } /> - name0 + label0
  • @@ -85,7 +85,7 @@ exports[`Breadcrumb should render with items 1`] = `
  • with items 1`] = ` className="link" onClick={[Function]} > - name0 + label0
  • with items 1`] = ` } } /> - name1 + label1
  • diff --git a/src/connectors/breadcrumb/__tests__/connectBreadcrumb-test.js b/src/connectors/breadcrumb/__tests__/connectBreadcrumb-test.js index e2e0fed69c..08ec167a0c 100644 --- a/src/connectors/breadcrumb/__tests__/connectBreadcrumb-test.js +++ b/src/connectors/breadcrumb/__tests__/connectBreadcrumb-test.js @@ -198,7 +198,7 @@ describe('connectBreadcrumb', () => { const secondRenderingOptions = rendering.mock.calls[1][0]; expect(secondRenderingOptions.items).toEqual([ - { name: 'Decoration', value: null }, + { label: 'Decoration', value: null }, ]); }); @@ -251,7 +251,7 @@ describe('connectBreadcrumb', () => { const widget = makeWidget({ attributes: ['category', 'sub_category'], transformItems: items => - items.map(item => ({ ...item, name: 'transformed' })), + items.map(item => ({ ...item, label: 'transformed' })), }); const config = widget.getConfiguration({}); @@ -299,7 +299,7 @@ describe('connectBreadcrumb', () => { const secondRenderingOptions = rendering.mock.calls[1][0]; expect(secondRenderingOptions.items).toEqual([ - expect.objectContaining({ name: 'transformed' }), + expect.objectContaining({ label: 'transformed' }), ]); }); diff --git a/src/connectors/breadcrumb/connectBreadcrumb.js b/src/connectors/breadcrumb/connectBreadcrumb.js index 6b869397a9..a3f44f2e03 100644 --- a/src/connectors/breadcrumb/connectBreadcrumb.js +++ b/src/connectors/breadcrumb/connectBreadcrumb.js @@ -24,7 +24,7 @@ Full documentation available at https://community.algolia.com/instantsearch.js/v /** * @typedef {Object} BreadcrumbItem - * @property {string} name Name of the category or subcategory. + * @property {string} label Label of the category or subcategory. * @property {string} value Value of breadcrumb item. */ @@ -181,7 +181,7 @@ function prepareItems(data) { return data.reduce((result, currentItem) => { if (currentItem.isRefined) { result.push({ - name: currentItem.name, + label: currentItem.name, value: currentItem.path, }); if (Array.isArray(currentItem.data)) { @@ -194,7 +194,7 @@ function prepareItems(data) { function shiftItemsValues(array) { return array.map((x, idx) => ({ - name: x.name, + label: x.label, value: idx + 1 === array.length ? null : array[idx + 1].value, })); } diff --git a/src/widgets/breadcrumb/__tests__/__snapshots__/breadcrumb-test.js.snap b/src/widgets/breadcrumb/__tests__/__snapshots__/breadcrumb-test.js.snap index 0e80880523..0ac97a5518 100644 --- a/src/widgets/breadcrumb/__tests__/__snapshots__/breadcrumb-test.js.snap +++ b/src/widgets/breadcrumb/__tests__/__snapshots__/breadcrumb-test.js.snap @@ -18,12 +18,12 @@ exports[`breadcrumb() render renders transformed items correctly 1`] = ` items={ Array [ Object { - "name": "Cameras & Camcorders", + "label": "Cameras & Camcorders", "transformed": true, "value": "Cameras & Camcorders > Digital Cameras", }, Object { - "name": "Digital Cameras", + "label": "Digital Cameras", "transformed": true, "value": null, },