From afc92c2d27aedfd6f427e5ce02b49808081e8ec2 Mon Sep 17 00:00:00 2001 From: Ely Lucas Date: Thu, 9 May 2019 13:26:18 -0600 Subject: [PATCH 1/2] fix(react): making children prop optional on overlay components --- react/src/components/createControllerComponent.tsx | 4 ++-- react/src/components/createOverlayComponent.tsx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/react/src/components/createControllerComponent.tsx b/react/src/components/createControllerComponent.tsx index f467b071e10..84d0fba35d4 100644 --- a/react/src/components/createControllerComponent.tsx +++ b/react/src/components/createControllerComponent.tsx @@ -7,11 +7,11 @@ export function createControllerComponent) => void; } - type Props = T & ReactProps; + type Props = T & ReactControllerProps; return class ReactControllerComponent extends React.Component { element: E; diff --git a/react/src/components/createOverlayComponent.tsx b/react/src/components/createOverlayComponent.tsx index 09c11d81c89..d5b3a6c2e0a 100644 --- a/react/src/components/createOverlayComponent.tsx +++ b/react/src/components/createOverlayComponent.tsx @@ -9,14 +9,14 @@ export function createOverlayComponent) => void; } - type Props = T & ReactProps; + type Props = T & ReactOverlayProps; - return class ReactControllerComponent extends React.Component { + return class ReactOverlayComponent extends React.Component { element: E; controllerElement: C; el: HTMLDivElement; From 3e3abb10831f2b26df47711e98537c388bf52757 Mon Sep 17 00:00:00 2001 From: Ely Lucas Date: Mon, 13 May 2019 16:57:13 -0600 Subject: [PATCH 2/2] fix(react): passing in defaultHref so it can be used if there is no prev view --- react/src/components/navigation/IonRouterOutlet.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/react/src/components/navigation/IonRouterOutlet.tsx b/react/src/components/navigation/IonRouterOutlet.tsx index c51823b7c4e..429db87ac8f 100644 --- a/react/src/components/navigation/IonRouterOutlet.tsx +++ b/react/src/components/navigation/IonRouterOutlet.tsx @@ -32,7 +32,7 @@ interface State { } interface ContextInterface { - goBack: () => void + goBack: (defaultHref?: string) => void } const Context = React.createContext({ @@ -152,11 +152,11 @@ class RouterOutlet extends Component { }); } - goBack = () => { + goBack = (defaultHref?: string) => { const prevView = this.state.views.find(v => v.id === this.state.activeId); const newView = this.state.views.find(v => v.id === prevView.prevId); - - this.props.history.replace(newView.location.pathname); + const newPath = newView ? newView.location.pathname : defaultHref; + this.props.history.replace(newPath); } componentDidUpdate() { @@ -232,8 +232,7 @@ export class IonBackButton extends Component { clickButton = (e: MouseEvent) => { e.stopPropagation(); - - this.context.goBack(); + this.context.goBack(this.props.defaultHref); } render() {