From 2a0a68772909496f2c132354aa1abefea0a56134 Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Thu, 27 Jun 2024 09:45:03 -0400 Subject: [PATCH] Move back to minimize diff --- packages/react/src/NavList/NavList.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/react/src/NavList/NavList.tsx b/packages/react/src/NavList/NavList.tsx index beb93b399e08..2ba2fc0d2c0c 100644 --- a/packages/react/src/NavList/NavList.tsx +++ b/packages/react/src/NavList/NavList.tsx @@ -70,20 +70,19 @@ const Item = React.forwardRef( // Get SubNav from children const subNav = React.Children.toArray(children).find(child => isValidElement(child) && child.type === SubNav) + // Get children without SubNav or TrailingAction + const childrenWithoutSubNavOrTrailingAction = React.Children.toArray(children).filter(child => + isValidElement(child) ? child.type !== SubNav && child.type !== TrailingAction : true, + ) + if (!isValidElement(subNav) && defaultOpen) // eslint-disable-next-line no-console console.error('NavList.Item must have a NavList.SubNav to use defaultOpen.') // Render ItemWithSubNav if SubNav is present if (subNav && isValidElement(subNav)) { - // Filter out TrailingAction - const childrenWithoutSubNavOrTrailingAction = React.Children.toArray(children).filter(child => - isValidElement(child) ? child.type !== SubNav && child.type !== TrailingAction : true, - ) - return ( - {/* This is a trailing action */} {childrenWithoutSubNavOrTrailingAction} )