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' ;
78import { getTeamByPersonName } from '@site/src/components/about' ;
89import styles from "@site/src/components/about/styles.module.css" ;
910
11+
12+
1013export default function LargePortraitCardPage ( ) {
1114 const location = useLocation ( ) ;
1215 const history = useHistory ( ) ;
1316
14- function handleClose ( ) {
17+ useEffect ( ( ) => {
1518 if ( location . state ?. fromAbout ) {
16- history . push ( '/about' ) ;
19+ window . scrollTo ( { top : location . state . scrollY ?? 0 , behavior : 'auto' } ) ;
20+ }
21+ } , [ ] ) ;
22+
23+ const handleOverlayClick = ( ) => {
24+ const scrollY = location . state ?. scrollY ;
25+
26+
27+ // Restore after a short delay
28+ setTimeout ( ( ) => {
29+ if ( scrollY !== undefined ) {
30+ window . scrollTo ( { top : scrollY , behavior : 'auto' } ) ;
31+ }
32+ } , 0 ) ;
33+ history . replace ( '/about' ) ;
34+ } ;
35+
36+ const handleClose = ( ) => {
37+ const scrollY = location . state ?. scrollY ;
38+
39+ if ( location . state ?. fromAbout ) {
40+ history . replace ( '/about' ) ;
41+
42+ setTimeout ( ( ) => {
43+ if ( scrollY !== undefined ) {
44+ window . scrollTo ( { top : scrollY , behavior : 'auto' } ) ;
45+ }
46+ } , 0 ) ;
1747 } else {
1848 history . goBack ( ) ;
1949 }
@@ -24,13 +54,13 @@ export default function LargePortraitCardPage() {
2454 < Route
2555 path = "/about/:completeName"
2656 render = { ( { history, match } ) => {
27- const { completeName } = match . params ;
57+ const { completeName } = match . params ; /* extract the dynamic part from the url i.e. the completeName*/
2858 const teamMembers = getTeamByPersonName ( completeName ) ;
29- const person = teamMembers . find ( person => person . completeName . replace ( / \s + / g, '' ) === completeName ) ;
59+ const person = teamMembers . find ( ( person ) => person . completeName . replace ( / \s + / g , '' ) . normalize ( "NFD" ) . replace ( / [ \u0300 - \u036f ] / g, '' ) === completeName ) ;
3060 if ( ! person ) return null ;
3161
3262 return (
33- < div className = { styles . modal_overlay } onClick = { ( ) => history . push ( '/about' ) } >
63+ < div className = { styles . modal_overlay } onClick = { handleOverlayClick } >
3464 < div
3565 className = { styles . modal_content }
3666 onClick = { ( e ) => e . stopPropagation ( ) }
0 commit comments