Skip to content

Commit

Permalink
Fixed back link issue on opening with empty referrer (#3981)
Browse files Browse the repository at this point in the history
* Fixed back link issue on opening with empty referrer

* Made suggested fix on non null assertion
  • Loading branch information
vrrayz authored Dec 20, 2022
1 parent 31a1067 commit b9e887b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const WorkingGroupOpening = () => {
header={
<PageHeaderWrapper>
<PageHeaderRow>
<PreviousPage>
<PreviousPage customLink={WorkingGroupsRoutes.openings}>
<PageTitle>{opening.title}</PageTitle>
</PreviousPage>
<ButtonsGroup>
Expand Down
14 changes: 11 additions & 3 deletions packages/ui/src/common/components/page/PreviousPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { History } from 'history'
import React from 'react'
import { useHistory } from 'react-router-dom'
import styled from 'styled-components'
Expand All @@ -8,14 +9,21 @@ import { Arrow } from '../icons'
interface PreviousPageProps {
children?: React.ReactNode
showOverflow?: boolean
customLink?: string
}

export const PreviousPage = ({ children, showOverflow }: PreviousPageProps) => {
const setPrevHistory = (history: History<unknown>, customLink?: string) => {
if (history.action === 'POP' && customLink) {
history.push(customLink)
} else {
history.goBack()
}
}
export const PreviousPage = ({ children, showOverflow, customLink }: PreviousPageProps) => {
const history = useHistory()
return (
<PreviousPageBlock showOverflow={showOverflow}>
<PreviousPageButtonContainer>
<PreviousPageButton onClick={() => history.goBack()} size="small" square>
<PreviousPageButton onClick={() => setPrevHistory(history, customLink)} size="small" square>
<BackArrow direction="left" />
</PreviousPageButton>
</PreviousPageButtonContainer>
Expand Down

2 comments on commit b9e887b

@vercel
Copy link

@vercel vercel bot commented on b9e887b Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on b9e887b Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pioneer-2 – ./

pioneer-2-joystream.vercel.app
pioneer-2.vercel.app
pioneer-2-git-dev-joystream.vercel.app

Please sign in to comment.