From 1a91b6a1f6493deb1dd9a7beead8db921751c5a1 Mon Sep 17 00:00:00 2001 From: David Szabo Date: Wed, 16 Sep 2020 12:12:19 +0200 Subject: [PATCH 1/4] Guard against setting a non-existing item or menu --- packages/components/src/navigation/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/components/src/navigation/index.js b/packages/components/src/navigation/index.js index 4919eca4861d67..737868d6820c77 100644 --- a/packages/components/src/navigation/index.js +++ b/packages/components/src/navigation/index.js @@ -30,6 +30,11 @@ export default function Navigation( { const navigationTree = useCreateNavigationTree(); const setActiveMenu = ( menuId, slideInOrigin = 'left' ) => { + const menuExists = !! navigationTree.getMenu( menuId ); + if ( ! menuExists ) { + return; + } + setSlideOrigin( slideInOrigin ); setMenu( menuId ); onActivateMenu( menuId ); From 37ee87dcdb911a69df3579fdf58dbd0b622d6f11 Mon Sep 17 00:00:00 2001 From: David Szabo Date: Wed, 16 Sep 2020 12:12:32 +0200 Subject: [PATCH 2/4] Update story --- packages/components/src/navigation/stories/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/components/src/navigation/stories/index.js b/packages/components/src/navigation/stories/index.js index a632d35dd6454d..c41ccbb5ff9a5a 100644 --- a/packages/components/src/navigation/stories/index.js +++ b/packages/components/src/navigation/stories/index.js @@ -71,6 +71,11 @@ function Example() { navigateToMenu="category" title="Category" /> + Date: Thu, 17 Sep 2020 09:13:41 +0200 Subject: [PATCH 3/4] Align item title to the left --- packages/components/src/navigation/styles/navigation-styles.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/src/navigation/styles/navigation-styles.js b/packages/components/src/navigation/styles/navigation-styles.js index 501bd32cab2b72..1b2953c16364b5 100644 --- a/packages/components/src/navigation/styles/navigation-styles.js +++ b/packages/components/src/navigation/styles/navigation-styles.js @@ -103,4 +103,5 @@ export const ItemBadgeUI = styled.span` export const ItemTitleUI = styled( Text )` margin-right: auto; + text-align: left; `; From 7afed17ed25a161e840257a449ee3731a949c590 Mon Sep 17 00:00:00 2001 From: David Szabo Date: Thu, 17 Sep 2020 15:38:23 +0200 Subject: [PATCH 4/4] Embed condition into if --- packages/components/src/navigation/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/components/src/navigation/index.js b/packages/components/src/navigation/index.js index 737868d6820c77..254d5ab24a9dfd 100644 --- a/packages/components/src/navigation/index.js +++ b/packages/components/src/navigation/index.js @@ -30,8 +30,7 @@ export default function Navigation( { const navigationTree = useCreateNavigationTree(); const setActiveMenu = ( menuId, slideInOrigin = 'left' ) => { - const menuExists = !! navigationTree.getMenu( menuId ); - if ( ! menuExists ) { + if ( ! navigationTree.getMenu( menuId ) ) { return; }