From 8b6aa3b50f0598c72040c31023a6c514b483053b Mon Sep 17 00:00:00 2001 From: Katie McFaul Date: Fri, 22 Nov 2024 14:48:49 -0500 Subject: [PATCH] update drawer behavior when other drawer is opened --- packages/dev/src/AppCustomDrawer.tsx | 28 +++++++++++++------ .../examples/WithCustomDrawer.jsx | 28 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/packages/dev/src/AppCustomDrawer.tsx b/packages/dev/src/AppCustomDrawer.tsx index 1269ff22..5f6af2ff 100644 --- a/packages/dev/src/AppCustomDrawer.tsx +++ b/packages/dev/src/AppCustomDrawer.tsx @@ -92,7 +92,10 @@ const App: React.FC = ({ children, showCardFooters }) => { }; const [modalOpen, setModalOpen] = React.useState(false); - const onClose = () => setActiveQuickStartID(''); + const onClose = () => { + setActiveQuickStartID(''); + setDrawerContent('none'); + }; const handleClose = (activeQuickStartStatus: string | number) => { if (activeQuickStartStatus === QuickStartStatus.IN_PROGRESS) { setModalOpen(true); @@ -107,14 +110,14 @@ const App: React.FC = ({ children, showCardFooters }) => { }; const onModalCancel = () => setModalOpen(false); - const [otherDrawerOpen, setOtherDrawerOpen] = React.useState(false); + const [drawerContent, setDrawerContent] = React.useState('none'); const otherDrawerPanelContent = ( - Drawer panel header + Drawer panel header - setOtherDrawerOpen(false)} /> + setDrawerContent('none')} /> Drawer panel description @@ -125,10 +128,10 @@ const App: React.FC = ({ children, showCardFooters }) => { return ( }> - + ) : ( otherDrawerPanelContent @@ -139,11 +142,20 @@ const App: React.FC = ({ children, showCardFooters }) => { - {children} diff --git a/packages/module/patternfly-docs/content/extensions/quick-starts/examples/WithCustomDrawer.jsx b/packages/module/patternfly-docs/content/extensions/quick-starts/examples/WithCustomDrawer.jsx index 00881cff..847a24cb 100644 --- a/packages/module/patternfly-docs/content/extensions/quick-starts/examples/WithCustomDrawer.jsx +++ b/packages/module/patternfly-docs/content/extensions/quick-starts/examples/WithCustomDrawer.jsx @@ -74,7 +74,10 @@ export const App = ({ showCardFooters }) => { }; const [modalOpen, setModalOpen] = React.useState(false); - const onClose = () => setActiveQuickStartID(''); + const onClose = () => { + setActiveQuickStartID(''); + setDrawerContent('none'); + }; const handleClose = (activeQuickStartStatus) => { if (activeQuickStartStatus === QuickStartStatus.IN_PROGRESS) { setModalOpen(true); @@ -88,14 +91,14 @@ export const App = ({ showCardFooters }) => { }; const onModalCancel = () => setModalOpen(false); - const [otherDrawerOpen, setOtherDrawerOpen] = React.useState(false); + const [drawerContent, setDrawerContent] = React.useState('none'); const otherDrawerPanelContent = ( - Drawer panel header + Drawer panel header - setOtherDrawerOpen(false)} /> + setDrawerContent('none')} /> Drawer panel description @@ -106,10 +109,10 @@ export const App = ({ showCardFooters }) => { return ( }> - + ) : ( otherDrawerPanelContent @@ -119,11 +122,20 @@ export const App = ({ showCardFooters }) => { -