From 32bd68da8d4a6d42cd6dc758f289ed33f68e20c0 Mon Sep 17 00:00:00 2001
From: nikita-jpg <56046344+nikita-jpg@users.noreply.github.com>
Date: Fri, 29 Mar 2024 10:56:41 +0300
Subject: [PATCH] fix(OnboardingMenu): bad useMemo Icon, took out the expand
state (#172)
---
.../OnboardingMenu/OnboardingMenu.scss | 2 +-
.../OnboardingMenu/OnboardingMenu.tsx | 22 ++++++++-----------
.../__stories__/OnboardingMenu.stories.tsx | 14 +++++-------
.../components/OnboardingMenuItem.tsx | 2 +-
4 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/src/components/OnboardingMenu/OnboardingMenu.scss b/src/components/OnboardingMenu/OnboardingMenu.scss
index 6c943b99..2d4eda43 100644
--- a/src/components/OnboardingMenu/OnboardingMenu.scss
+++ b/src/components/OnboardingMenu/OnboardingMenu.scss
@@ -70,7 +70,7 @@ $block: '.#{variables.$ns}onboarding-menu';
&__lining {
overflow-y: auto;
- max-height: 684px;
+ max-height: 530px;
box-sizing: border-box;
diff --git a/src/components/OnboardingMenu/OnboardingMenu.tsx b/src/components/OnboardingMenu/OnboardingMenu.tsx
index 4125ef90..f5034f89 100644
--- a/src/components/OnboardingMenu/OnboardingMenu.tsx
+++ b/src/components/OnboardingMenu/OnboardingMenu.tsx
@@ -18,7 +18,7 @@ export type OnboardingMenuProps = {
progress: number;
icon?: IconData;
- defaultExpanded: boolean;
+ expanded: boolean;
children?: React.ReactNode;
collapseButtonText?: string;
@@ -34,7 +34,7 @@ const OnboardingMenuParent = ({
title,
progress,
icon,
- defaultExpanded,
+ expanded,
onExpand,
onCollapseClick,
onCompleteClick,
@@ -43,21 +43,17 @@ const OnboardingMenuParent = ({
className,
children,
}: OnboardingMenuProps) => {
- const [expand, setExpand] = React.useState(defaultExpanded);
-
const onExpandCallback = () => {
- const newExpand = !expand;
+ const newExpand = !expanded;
- setExpand(newExpand);
if (onExpand) {
onExpand(newExpand);
}
};
const onCollapseClickCallback = (event: React.MouseEvent) => {
- const newExpand = !expand;
+ const newExpand = !expanded;
- setExpand(newExpand);
if (onCollapseClick) {
onCollapseClick(event);
}
@@ -68,10 +64,10 @@ const OnboardingMenuParent = ({
return (
-
-
+
+
- {expand && (
+ {expanded && (
{children}
diff --git a/src/components/OnboardingMenu/__stories__/OnboardingMenu.stories.tsx b/src/components/OnboardingMenu/__stories__/OnboardingMenu.stories.tsx
index 65f53671..24476fa4 100644
--- a/src/components/OnboardingMenu/__stories__/OnboardingMenu.stories.tsx
+++ b/src/components/OnboardingMenu/__stories__/OnboardingMenu.stories.tsx
@@ -7,7 +7,6 @@ import type {Meta, Story} from '@storybook/react';
import type {OnboardingMenuProps} from '../OnboardingMenu';
import {OnboardingMenu} from '../OnboardingMenu';
-// import {OnboardingMenu.ItemImage} from '../OnboardingMenu.ItemImage';
export default {
title: 'Components/OnboardingMenu',
@@ -18,14 +17,18 @@ const actionsButtonHandlers = () => actions('onClick').onClick('Click on the but
const actionsButtonComplete = () => actions('onClick').onClick('Click on the end button');
const DefaultTemplate: Story
= (args) => {
- const actionsOnboardingMenuHandlers = () => {
+ const [expanded, setExpanded] = React.useState(false);
+
+ const actionsOnboardingMenuHandlers = (expanded: boolean) => {
actions('onHeaderClick').onHeaderClick('Click on the header');
+ setExpanded(expanded);
};
return (
{[]}
@@ -585,14 +584,12 @@ SomeIcons.args = {
WithoutArrow.args = {
title: 'Header text',
progress: 30,
- defaultExpanded: true,
children: [],
};
CustomButtonText.args = {
title: 'Header text',
progress: 30,
- defaultExpanded: true,
collapseButtonText: 'left button',
completeButtonText: 'right button',
};
@@ -600,7 +597,6 @@ CustomButtonText.args = {
Custom.args = {
title: 'Different icons',
progress: 30,
- defaultExpanded: true,
className: 'testName',
children: [
'Custom reaction node',
diff --git a/src/components/OnboardingMenu/components/OnboardingMenuItem.tsx b/src/components/OnboardingMenu/components/OnboardingMenuItem.tsx
index d4cfc037..9b593ed9 100644
--- a/src/components/OnboardingMenu/components/OnboardingMenuItem.tsx
+++ b/src/components/OnboardingMenu/components/OnboardingMenuItem.tsx
@@ -56,7 +56,7 @@ export const OnboardingMenuItem = ({
className={cnOnboardingMenuItem('status-icon_disabled')}
/>
);
- }, []);
+ }, [status]);
const summary = (