diff --git a/ghost/portal/src/App.js b/ghost/portal/src/App.js index f99cfed041..b133d574f7 100644 --- a/ghost/portal/src/App.js +++ b/ghost/portal/src/App.js @@ -268,12 +268,14 @@ export default class App extends React.Component { const updatedState = await ActionHandler({action, data, state: this.state, api: this.GhostApi}); this.setState(updatedState); - /** Reset action state after short timeout */ - this.timeoutId = setTimeout(() => { - this.setState({ - action: '' - }); - }, 2000); + /** Reset action state after short timeout if not failed*/ + if (updatedState && updatedState.action && !updatedState.action.includes(':failed')) { + this.timeoutId = setTimeout(() => { + this.setState({ + action: '' + }); + }, 2000); + } } catch (error) { const popupNotification = createPopupNotification({ type: `${action}:failed`, diff --git a/ghost/portal/src/actions.js b/ghost/portal/src/actions.js index 1c44412ad6..0091160486 100644 --- a/ghost/portal/src/actions.js +++ b/ghost/portal/src/actions.js @@ -297,7 +297,7 @@ async function updateProfile({data, state, api}) { return { action, ...(dataUpdate.success ? {member: dataUpdate.member} : {}), - page: 'accountHome', + ...(dataUpdate.success ? {page: 'accountHome'} : {}), popupNotification: createPopupNotification({ type: action, autoHide: dataUpdate.success, closeable: true, status, state, message }) @@ -308,6 +308,7 @@ async function updateProfile({data, state, api}) { const message = !emailUpdate.success ? 'Failed to send verification email' : 'Check your inbox to verify email update'; return { action, + ...(emailUpdate.success ? {page: 'accountHome'} : {}), popupNotification: createPopupNotification({ type: action, autoHide: emailUpdate.success, closeable: true, status, state, message }) diff --git a/ghost/portal/src/components/common/PopupNotification.js b/ghost/portal/src/components/common/PopupNotification.js index 51e1b22928..3e384e8ff7 100644 --- a/ghost/portal/src/components/common/PopupNotification.js +++ b/ghost/portal/src/components/common/PopupNotification.js @@ -126,9 +126,7 @@ export default class PopupNotification extends React.Component { } closeNotification(e) { - this.setState({ - className: 'slideout' - }); + this.context.onAction('clearPopupNotification'); } componentDidUpdate() { diff --git a/ghost/portal/src/components/pages/AccountProfilePage.js b/ghost/portal/src/components/pages/AccountProfilePage.js index 1eda2d1c01..b34e238e9c 100644 --- a/ghost/portal/src/components/pages/AccountProfilePage.js +++ b/ghost/portal/src/components/pages/AccountProfilePage.js @@ -48,6 +48,7 @@ export default class AccountProfilePage extends React.Component { const {email, name, errors} = this.state; const hasFormErrors = (errors && Object.values(errors).filter(d => !!d).length > 0); if (!hasFormErrors) { + this.context.onAction('clearPopupNotification'); this.context.onAction('updateProfile', {email, name}); } });