-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closing a Callout takes the user to Callout Location (#5461)
* Closing a Callout takes the user to Callout Location * rename --------- Co-authored-by: Carlos Cano <[email protected]>
- Loading branch information
Showing
11 changed files
with
42 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useCallback } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import useCanGoBack from './useCanGoBack'; | ||
|
||
/** | ||
* Goes back only if the previous history item has the specified URL. | ||
* This is based on the native browser history API, so it may not work with all flavors of react-router. | ||
*/ | ||
const useBackToPath = () => { | ||
const navigate = useNavigate(); | ||
const canGoBack = useCanGoBack(); | ||
|
||
return useCallback((parentPagePath: string) => { | ||
if (!canGoBack) { | ||
navigate(parentPagePath); | ||
} | ||
const handlePopState = () => { | ||
window.removeEventListener('popstate', handlePopState); | ||
if (window.location.pathname !== parentPagePath) { | ||
navigate(parentPagePath); | ||
} | ||
}; | ||
window.addEventListener('popstate', handlePopState); | ||
navigate(-1); | ||
}, []); | ||
}; | ||
|
||
export default useBackToPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/domain/collaboration/whiteboard/EntityWhiteboardPage/WhiteboardsView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters