From 9d853be9796e3df34540e620727fba425f757b05 Mon Sep 17 00:00:00 2001 From: Rish Date: Wed, 18 Nov 2020 16:02:31 +0530 Subject: [PATCH] Fixed incorrect link/path handling no refs Last release broke the handling of incorrect portal link or attribute as no default value was used for link path --- ghost/portal/src/App.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ghost/portal/src/App.js b/ghost/portal/src/App.js index 9799d88aa4..6ee41831fe 100644 --- a/ghost/portal/src/App.js +++ b/ghost/portal/src/App.js @@ -62,12 +62,14 @@ export default class App extends React.Component { setupCustomTriggerButton() { // Handler for custom buttons this.clickHandler = (event) => { + event.preventDefault(); const target = event.currentTarget; const pagePath = (target && target.dataset.portal); - const {page, pageQuery} = this.getPageFromLinkPath(pagePath); + const {page, pageQuery} = this.getPageFromLinkPath(pagePath) || {}; - event.preventDefault(); - this.onAction('openPopup', {page, pageQuery}); + if (page) { + this.onAction('openPopup', {page, pageQuery}); + } }; const customTriggerSelector = '[data-portal]'; const popupCloseClass = 'gh-members-popup-close'; @@ -227,7 +229,7 @@ export default class App extends React.Component { const linkRegex = /^\/portal(?:\/(\w+(?:\/\w+)?))?$/; if (path && linkRegex.test(path)) { const [,pagePath] = path.match(linkRegex); - const {page, pageQuery} = this.getPageFromLinkPath(pagePath); + const {page, pageQuery} = this.getPageFromLinkPath(pagePath) || {}; const lastPage = ['accountPlan', 'accountProfile'].includes(page) ? 'accountHome' : null; return { showPopup: true,