1
1
import React from 'react' ;
2
2
import Layout from '@theme/Layout' ;
3
- import { useHistory , useLocation } from '@docusaurus/router' ;
3
+ import { useHistory , useLocation } from '@docusaurus/router' ;
4
+ import { useEffect } from 'react' ;
4
5
import { Route } from 'react-router-dom' ;
5
6
import { About } from '@site/src/components/about'
6
7
import LargePortraitCard from '@site/src/components/about/LargePortraitCard' ;
@@ -11,9 +12,32 @@ export default function LargePortraitCardPage() {
11
12
const location = useLocation ( ) ;
12
13
const history = useHistory ( ) ;
13
14
14
- function handleClose ( ) {
15
+ useEffect ( ( ) => {
15
16
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 ) ;
17
41
} else {
18
42
history . goBack ( ) ;
19
43
}
@@ -24,13 +48,13 @@ export default function LargePortraitCardPage() {
24
48
< Route
25
49
path = "/about/:completeName"
26
50
render = { ( { history, match } ) => {
27
- const { completeName } = match . params ;
51
+ const { completeName } = match . params ; /* extract the dynamic part from the url i.e. the completeName*/
28
52
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 ) ;
30
54
if ( ! person ) return null ;
31
55
32
56
return (
33
- < div className = { styles . modal_overlay } onClick = { ( ) => history . push ( '/about' ) } >
57
+ < div className = { styles . modal_overlay } onClick = { handleOverlayClick } >
34
58
< div
35
59
className = { styles . modal_content }
36
60
onClick = { ( e ) => e . stopPropagation ( ) }
0 commit comments