From a9eb40a7163bfdd5b49c48fb77a6070f2e8fbe20 Mon Sep 17 00:00:00 2001 From: Viet Anh Tran Date: Mon, 23 Dec 2024 13:43:21 +1300 Subject: [PATCH 01/10] Simplify KaizenProvider --- packages/components/src/KaizenProvider/KaizenProvider.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/components/src/KaizenProvider/KaizenProvider.tsx b/packages/components/src/KaizenProvider/KaizenProvider.tsx index 3f178d76aa3..f8cbf0f2b22 100644 --- a/packages/components/src/KaizenProvider/KaizenProvider.tsx +++ b/packages/components/src/KaizenProvider/KaizenProvider.tsx @@ -11,21 +11,19 @@ export type KaizenProviderProps = { export const KaizenProvider = ({ children, locale = 'en' }: KaizenProviderProps): JSX.Element => { const [documentIsAvailable, setDocumentIsAvailable] = useState(false) - const [notificationsList, setNotificationsList] = useState() useEffect(() => { // SSR does not have a document, which is required for ToastNotificationsList. // Await document render before rendering the component. if (document !== undefined) { - setNotificationsList() setDocumentIsAvailable(true) } - }, [documentIsAvailable]) + }, []) return ( - {notificationsList} + {documentIsAvailable && } {children} From bc6f4497c8433e1406463908a4fd61f4b85ab3b6 Mon Sep 17 00:00:00 2001 From: Viet Anh Tran Date: Mon, 23 Dec 2024 13:43:39 +1300 Subject: [PATCH 02/10] changeset --- .changeset/proud-cameras-lay.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/proud-cameras-lay.md diff --git a/.changeset/proud-cameras-lay.md b/.changeset/proud-cameras-lay.md new file mode 100644 index 00000000000..208bd219604 --- /dev/null +++ b/.changeset/proud-cameras-lay.md @@ -0,0 +1,5 @@ +--- +'@kaizen/components': patch +--- + +Simplify KaizenProvider From 9605a5b08648427bd9c60fc7f0c4adc2bd899291 Mon Sep 17 00:00:00 2001 From: Viet Anh Tran Date: Mon, 23 Dec 2024 14:47:31 +1300 Subject: [PATCH 03/10] Fix story --- .../_docs/ToastNotification.stories.tsx | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/components/src/Notification/ToastNotification/_docs/ToastNotification.stories.tsx b/packages/components/src/Notification/ToastNotification/_docs/ToastNotification.stories.tsx index 38921d18748..0211b18547f 100644 --- a/packages/components/src/Notification/ToastNotification/_docs/ToastNotification.stories.tsx +++ b/packages/components/src/Notification/ToastNotification/_docs/ToastNotification.stories.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useId } from 'react' import { type Meta, type StoryObj } from '@storybook/react' -import { expect, within } from '@storybook/test' +import { expect, within, userEvent } from '@storybook/test' import { Button } from '~components/Button' import { ToastNotification, useToastNotification } from '../index' @@ -175,26 +175,27 @@ export const NoDuplicatesWithSameId: Story = { render: () => { const { addToastNotification } = useToastNotification() - useEffect(() => { - addToastNotification({ - id: 'id--clear-example-1', - title: 'First', - type: 'positive', - message: 'There should only be one notification', - }) - addToastNotification({ - id: 'id--clear-example-1', - title: 'First', - type: 'positive', - message: 'There should only be one notification', - }) - }, [addToastNotification]) - - return
Irrelevant content
+ return ( +