11import React from 'react' ;
22import Layout from '@theme/Layout' ;
3- import { useHistory , useLocation } from '@docusaurus/router' ;
3+ import { useHistory , useLocation } from '@docusaurus/router' ;
4+ import { useEffect } from 'react' ;
45import { Route } from 'react-router-dom' ;
56import { About } from '@site/src/components/about'
67import LargePortraitCard from '@site/src/components/about/LargePortraitCard' ;
@@ -11,9 +12,32 @@ export default function LargePortraitCardPage() {
1112 const location = useLocation ( ) ;
1213 const history = useHistory ( ) ;
1314
14- function handleClose ( ) {
15+ useEffect ( ( ) => {
1516 if ( location . state ?. fromAbout ) {
16- history . push ( '/about' ) ;
17+ window . scrollTo ( { top : location . state . scrollY ?? 0 , behavior : 'auto' } ) ;
18+ }
19+ } , [ ] ) ;
20+
21+ const handleOverlayClick = ( ) => {
22+ const scrollY = location . state ?. scrollY ;
23+ setTimeout ( ( ) => {
24+ if ( scrollY !== undefined ) {
25+ window . scrollTo ( { top : scrollY , behavior : 'auto' } ) ;
26+ }
27+ } , 0 ) ;
28+ history . replace ( '/about' ) ;
29+ } ;
30+
31+ const handleClose = ( ) => {
32+ const scrollY = location . state ?. scrollY ;
33+ if ( location . state ?. fromAbout ) {
34+ history . replace ( '/about' ) ;
35+
36+ setTimeout ( ( ) => {
37+ if ( scrollY !== undefined ) {
38+ window . scrollTo ( { top : scrollY , behavior : 'auto' } ) ;
39+ }
40+ } , 0 ) ;
1741 } else {
1842 history . goBack ( ) ;
1943 }
@@ -24,13 +48,13 @@ export default function LargePortraitCardPage() {
2448 < Route
2549 path = "/about/:completeName"
2650 render = { ( { history, match } ) => {
27- const { completeName } = match . params ;
51+ const { completeName } = match . params ; /* extract the dynamic part from the url i.e. the completeName*/
2852 const teamMembers = getTeamByPersonName ( completeName ) ;
29- const person = teamMembers . find ( person => person . completeName . replace ( / \s + / g, '' ) === completeName ) ;
53+ const person = teamMembers . find ( ( person ) => person . completeName . replace ( / \s + / g , '' ) . normalize ( "NFD" ) . replace ( / [ \u0300 - \u036f ] / g, '' ) === completeName ) ;
3054 if ( ! person ) return null ;
3155
3256 return (
33- < div className = { styles . modal_overlay } onClick = { ( ) => history . push ( '/about' ) } >
57+ < div className = { styles . modal_overlay } onClick = { handleOverlayClick } >
3458 < div
3559 className = { styles . modal_content }
3660 onClick = { ( e ) => e . stopPropagation ( ) }
0 commit comments