Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): defaultHref fixes #18278

Merged
merged 3 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions react/src/components/createControllerComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export function createControllerComponent<T extends object, E extends OverlayCom
const displayName = dashToPascalCase(tagName);
const dismissEventName = `on${displayName}DidDismiss`;

type ReactProps = {
type ReactControllerProps = {
isOpen: boolean;
onDidDismiss: (event: CustomEvent<OverlayEventDetail>) => void;
}
type Props = T & ReactProps;
type Props = T & ReactControllerProps;

return class ReactControllerComponent extends React.Component<Props> {
element: E;
Expand Down
8 changes: 4 additions & 4 deletions react/src/components/createOverlayComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export function createOverlayComponent<T extends object, E extends OverlayCompon
const displayName = dashToPascalCase(tagName);
const dismissEventName = `on${displayName}DidDismiss`;

type ReactProps = {
children: React.ReactNode;
type ReactOverlayProps = {
children?: React.ReactNode;
isOpen: boolean;
onDidDismiss: (event: CustomEvent<OverlayEventDetail>) => void;
}
type Props = T & ReactProps;
type Props = T & ReactOverlayProps;

return class ReactControllerComponent extends React.Component<Props> {
return class ReactOverlayComponent extends React.Component<Props> {
element: E;
controllerElement: C;
el: HTMLDivElement;
Expand Down
11 changes: 5 additions & 6 deletions react/src/components/navigation/IonRouterOutlet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface State {
}

interface ContextInterface {
goBack: () => void
goBack: (defaultHref?: string) => void
}

const Context = React.createContext<ContextInterface>({
Expand Down Expand Up @@ -152,11 +152,11 @@ class RouterOutlet extends Component<Props, State> {
});
}

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() {
Expand Down Expand Up @@ -232,8 +232,7 @@ export class IonBackButton extends Component<ButtonProps> {

clickButton = (e: MouseEvent) => {
e.stopPropagation();

this.context.goBack();
this.context.goBack(this.props.defaultHref);
}

render() {
Expand Down