From e02d5142e5d913757585176900d0641b9692d7cc Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 21 Mar 2022 15:23:57 -0400 Subject: [PATCH] Properly handle navigating to previous page if 'backHref' is undefined --- app/soapbox/components/ui/column/column.tsx | 22 ++++++++++++++++---- app/soapbox/features/edit_profile/index.js | Bin 17630 -> 17004 bytes 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/soapbox/components/ui/column/column.tsx b/app/soapbox/components/ui/column/column.tsx index a9c5f0d2e1..08ef17b9a3 100644 --- a/app/soapbox/components/ui/column/column.tsx +++ b/app/soapbox/components/ui/column/column.tsx @@ -1,10 +1,11 @@ import React from 'react'; +import { RouteComponentProps, withRouter } from 'react-router-dom'; import Helmet from 'soapbox/components/helmet'; import { Card, CardBody, CardHeader, CardTitle } from '../card/card'; -interface IColumn { +interface IColumn extends RouteComponentProps { backHref?: string, label?: string, transparent?: boolean, @@ -12,7 +13,20 @@ interface IColumn { } const Column: React.FC = React.forwardRef((props, ref: React.ForwardedRef): JSX.Element => { - const { backHref, children, label, transparent = false, withHeader = true } = props; + const { backHref, children, label, history, transparent = false, withHeader = true } = props; + + const handleBackClick = () => { + if (backHref) { + history.push(backHref); + return; + } + + if (history.length === 1) { + history.push('/'); + } else { + history.goBack(); + } + }; const renderChildren = () => { if (transparent) { @@ -22,7 +36,7 @@ const Column: React.FC = React.forwardRef((props, ref: React.ForwardedR return ( {withHeader ? ( - + ) : null} @@ -43,4 +57,4 @@ const Column: React.FC = React.forwardRef((props, ref: React.ForwardedR ); }); -export default Column; +export default withRouter(Column); diff --git a/app/soapbox/features/edit_profile/index.js b/app/soapbox/features/edit_profile/index.js index 4939bd13e01161b57d24f824187dff4ed83b9692..008711462c12b910721a5b56e423724cbc5fa76c 100644 GIT binary patch delta 470 zcmZY6JxBs^7zS|cL(U7szVNg&PQCNIJH4w+QSpO3X|bSaiXei5C^4h2Aqa_rXsl-{ z8l=V?BIjBg8X6*+w7qhPwjeq!1aW#_c>X`$2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