From 2dbc411616f7276d832bb5007f41a37c9c93f69e Mon Sep 17 00:00:00 2001 From: Marcos Kolodny Date: Thu, 29 Aug 2024 15:07:58 +0200 Subject: [PATCH 1/6] fix(Buttons): avoid warnings related to change in order of react hooks (#1229) --- src/button.tsx | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/button.tsx b/src/button.tsx index b3676fcd4..98f2c70b1 100644 --- a/src/button.tsx +++ b/src/button.tsx @@ -137,6 +137,20 @@ const renderButtonContent = ({ const defaultIconSize = small ? styles.iconSize.small : styles.iconSize.default; const spinnerSizeRem = small ? styles.spinnerSize.small : styles.spinnerSize.default; + const buttonElement = renderButtonElement({ + small, + content: children, + defaultIconSize, + TextContentRenderer, + }); + + const loadingButtonElement = renderButtonElement({ + small, + content: loadingText, + defaultIconSize, + TextContentRenderer, + }); + return ( <> {/* text content */} @@ -153,12 +167,7 @@ const renderButtonContent = ({ )}
- {renderButtonElement({ - small, - content: children, - defaultIconSize, - TextContentRenderer, - })} + {buttonElement} {withChevron && (
- {renderButtonElement({ - small, - content: loadingText, - defaultIconSize, - TextContentRenderer, - })} + {loadingButtonElement}
{/* loading content */} @@ -231,16 +235,7 @@ const renderButtonContent = ({ }} /> )} - {loadingText ? ( - - {renderButtonElement({ - small, - content: loadingText, - defaultIconSize, - TextContentRenderer, - })} - - ) : null} + {loadingText ? {loadingButtonElement} : null}
); From 768064701a8000e994a167061d1720b13ade9810 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 3 Sep 2024 12:15:33 +0000 Subject: [PATCH 2/6] chore(release): 15.19.0 [skip ci] # [15.19.0](https://github.com/Telefonica/mistica-web/compare/v15.18.0...v15.19.0) (2024-09-03) ### Bug Fixes * **Buttons:** avoid warnings related to change in order of react hooks ([#1229](https://github.com/Telefonica/mistica-web/issues/1229)) ([2dbc411](https://github.com/Telefonica/mistica-web/commit/2dbc411616f7276d832bb5007f41a37c9c93f69e)) * **i18n): Revert "feat(i18n:** improve texts sizes" because it is breaking ([#1226](https://github.com/Telefonica/mistica-web/issues/1226)) ([79eb4a4](https://github.com/Telefonica/mistica-web/commit/79eb4a427ef9f8d5a91bf56c8434ca1417a77df3)) * **Logo:** fix webpackChunkName magic comments ([#1214](https://github.com/Telefonica/mistica-web/issues/1214)) ([3d1f098](https://github.com/Telefonica/mistica-web/commit/3d1f098c6cbaf179b29de666ba824f1ae63dea9e)) * **Vivinho char:** vivinho char in headings being read as a separated heading ([#1209](https://github.com/Telefonica/mistica-web/issues/1209)) ([f0f5fb0](https://github.com/Telefonica/mistica-web/commit/f0f5fb05b99fc594479a19c3037cc9dfc7446bab)) ### Features * **Buttons:** refactor code and fix spacing bug in loading buttonLink ([#1212](https://github.com/Telefonica/mistica-web/issues/1212)) ([640e429](https://github.com/Telefonica/mistica-web/commit/640e429c8ab4493c5da1f39bad5fccf90eacc373)) * **i18n:** improve texts sizes ([#1204](https://github.com/Telefonica/mistica-web/issues/1204)) ([0345e7c](https://github.com/Telefonica/mistica-web/commit/0345e7cefd06b911377278b5928409cbed23f921)) * **Logo:** Refactor logo to improve bundle size and loading times ([#1210](https://github.com/Telefonica/mistica-web/issues/1210)) ([15b77cb](https://github.com/Telefonica/mistica-web/commit/15b77cb8ab932f68fb124d66887b8d49169b0095)) * **NavigationBar, FunnelNavigationBar, MainNavigationBar:** add alternative variant ([#1200](https://github.com/Telefonica/mistica-web/issues/1200)) ([eef87ec](https://github.com/Telefonica/mistica-web/commit/eef87ecdd32053f80f349aaf1598d8e61251b6eb)) --- CHANGELOG.md | 18 ++++++++++++++++++ package.json | 2 +- src/package-version.tsx | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f52b7877..9699010f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +# [15.19.0](https://github.com/Telefonica/mistica-web/compare/v15.18.0...v15.19.0) (2024-09-03) + + +### Bug Fixes + +* **Buttons:** avoid warnings related to change in order of react hooks ([#1229](https://github.com/Telefonica/mistica-web/issues/1229)) ([2dbc411](https://github.com/Telefonica/mistica-web/commit/2dbc411616f7276d832bb5007f41a37c9c93f69e)) +* **i18n): Revert "feat(i18n:** improve texts sizes" because it is breaking ([#1226](https://github.com/Telefonica/mistica-web/issues/1226)) ([79eb4a4](https://github.com/Telefonica/mistica-web/commit/79eb4a427ef9f8d5a91bf56c8434ca1417a77df3)) +* **Logo:** fix webpackChunkName magic comments ([#1214](https://github.com/Telefonica/mistica-web/issues/1214)) ([3d1f098](https://github.com/Telefonica/mistica-web/commit/3d1f098c6cbaf179b29de666ba824f1ae63dea9e)) +* **Vivinho char:** vivinho char in headings being read as a separated heading ([#1209](https://github.com/Telefonica/mistica-web/issues/1209)) ([f0f5fb0](https://github.com/Telefonica/mistica-web/commit/f0f5fb05b99fc594479a19c3037cc9dfc7446bab)) + + +### Features + +* **Buttons:** refactor code and fix spacing bug in loading buttonLink ([#1212](https://github.com/Telefonica/mistica-web/issues/1212)) ([640e429](https://github.com/Telefonica/mistica-web/commit/640e429c8ab4493c5da1f39bad5fccf90eacc373)) +* **i18n:** improve texts sizes ([#1204](https://github.com/Telefonica/mistica-web/issues/1204)) ([0345e7c](https://github.com/Telefonica/mistica-web/commit/0345e7cefd06b911377278b5928409cbed23f921)) +* **Logo:** Refactor logo to improve bundle size and loading times ([#1210](https://github.com/Telefonica/mistica-web/issues/1210)) ([15b77cb](https://github.com/Telefonica/mistica-web/commit/15b77cb8ab932f68fb124d66887b8d49169b0095)) +* **NavigationBar, FunnelNavigationBar, MainNavigationBar:** add alternative variant ([#1200](https://github.com/Telefonica/mistica-web/issues/1200)) ([eef87ec](https://github.com/Telefonica/mistica-web/commit/eef87ecdd32053f80f349aaf1598d8e61251b6eb)) + # [15.18.0](https://github.com/Telefonica/mistica-web/compare/v15.17.0...v15.18.0) (2024-08-20) diff --git a/package.json b/package.json index 0b46d2828..c8ead6ca7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@telefonica/mistica", - "version": "15.18.0", + "version": "15.19.0", "license": "MIT", "repository": { "type": "git", diff --git a/src/package-version.tsx b/src/package-version.tsx index 75b96d4de..c9a5cc3c4 100644 --- a/src/package-version.tsx +++ b/src/package-version.tsx @@ -1,2 +1,2 @@ // DO NOT EDIT THIS FILE. It's autogenerated by set-version.js -export const PACKAGE_VERSION = '15.18.0' as string; +export const PACKAGE_VERSION = '15.19.0' as string; From 3f99e4a85f4b810a5ee84abf8536384dde841749 Mon Sep 17 00:00:00 2001 From: Pedro Ladaria Date: Tue, 3 Sep 2024 14:20:34 +0200 Subject: [PATCH 3/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9699010f0..27c6331fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Bug Fixes * **Buttons:** avoid warnings related to change in order of react hooks ([#1229](https://github.com/Telefonica/mistica-web/issues/1229)) ([2dbc411](https://github.com/Telefonica/mistica-web/commit/2dbc411616f7276d832bb5007f41a37c9c93f69e)) -* **i18n): Revert "feat(i18n:** improve texts sizes" because it is breaking ([#1226](https://github.com/Telefonica/mistica-web/issues/1226)) ([79eb4a4](https://github.com/Telefonica/mistica-web/commit/79eb4a427ef9f8d5a91bf56c8434ca1417a77df3)) +* **i18n:** revert text sizes improvement because it is breaking ([#1226](https://github.com/Telefonica/mistica-web/issues/1226)) ([79eb4a4](https://github.com/Telefonica/mistica-web/commit/79eb4a427ef9f8d5a91bf56c8434ca1417a77df3)) * **Logo:** fix webpackChunkName magic comments ([#1214](https://github.com/Telefonica/mistica-web/issues/1214)) ([3d1f098](https://github.com/Telefonica/mistica-web/commit/3d1f098c6cbaf179b29de666ba824f1ae63dea9e)) * **Vivinho char:** vivinho char in headings being read as a separated heading ([#1209](https://github.com/Telefonica/mistica-web/issues/1209)) ([f0f5fb0](https://github.com/Telefonica/mistica-web/commit/f0f5fb05b99fc594479a19c3037cc9dfc7446bab)) From ec7ed8b93d0b6892827263d35373896a8cf291b6 Mon Sep 17 00:00:00 2001 From: Marcos Kolodny Date: Wed, 4 Sep 2024 12:15:09 +0200 Subject: [PATCH 4/6] feat(NavigationBreadcrumbs): allow executing onNavigate when pressing a link (#1233) --- src/__tests__/navigation-breadcrumbs-test.tsx | 33 +++++++++++++++++++ src/navigation-breadcrumbs.tsx | 4 ++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/__tests__/navigation-breadcrumbs-test.tsx diff --git a/src/__tests__/navigation-breadcrumbs-test.tsx b/src/__tests__/navigation-breadcrumbs-test.tsx new file mode 100644 index 000000000..19345c49a --- /dev/null +++ b/src/__tests__/navigation-breadcrumbs-test.tsx @@ -0,0 +1,33 @@ +import * as React from 'react'; +import {render, screen} from '@testing-library/react'; +import ThemeContextProvider from '../theme-context-provider'; +import {makeTheme} from './test-utils'; +import NavigationBreadcrumbs from '../navigation-breadcrumbs'; +import userEvent from '@testing-library/user-event'; + +test('Breadcrumbs onNavigate is called when pressing a link', async () => { + const navigateSpy = jest.fn(); + + render( + + navigateSpy('breadcrumb 1')}, + {title: 'breadcrumb 2', url: '#', onNavigate: () => navigateSpy('breadcrumb 2')}, + ]} + /> + + ); + + const firstLink = await screen.findByRole('link', {name: 'breadcrumb 1'}); + const secondLink = await screen.findByRole('link', {name: 'breadcrumb 2'}); + + await userEvent.click(firstLink); + expect(navigateSpy).toHaveBeenLastCalledWith('breadcrumb 1'); + expect(navigateSpy).toHaveBeenCalledTimes(1); + + await userEvent.click(secondLink); + expect(navigateSpy).toHaveBeenLastCalledWith('breadcrumb 2'); + expect(navigateSpy).toHaveBeenCalledTimes(2); +}); diff --git a/src/navigation-breadcrumbs.tsx b/src/navigation-breadcrumbs.tsx index c4c858741..e22f572a3 100644 --- a/src/navigation-breadcrumbs.tsx +++ b/src/navigation-breadcrumbs.tsx @@ -21,6 +21,7 @@ export type NavigationBreadcrumbsProps = { breadcrumbs: ReadonlyArray<{ readonly title: string; readonly url: string; + onNavigate?: () => void; }>; children?: void; dataAttributes?: DataAttributes; @@ -37,7 +38,7 @@ const NavigationBreadcrumbs: React.FC = ({ return (