Skip to content

Commit c893c09

Browse files
Fix issues related to last names like for those having with special characters.
Add logics to not scroll systematically to the top of the page when changing from about page to portrait ones and reciprocally.
1 parent 3756b2d commit c893c09

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

src/components/about/LargePortraitCardPage.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Layout from '@theme/Layout';
3-
import { useHistory, useLocation} from '@docusaurus/router';
3+
import { useHistory, useLocation } from '@docusaurus/router';
4+
import { useEffect } from 'react';
45
import { Route } from 'react-router-dom';
56
import { About } from '@site/src/components/about'
67
import LargePortraitCard from '@site/src/components/about/LargePortraitCard';
@@ -11,9 +12,23 @@ export default function LargePortraitCardPage() {
1112
const location = useLocation();
1213
const history = useHistory();
1314

15+
useEffect(() => {
16+
if (location.state?.fromAbout) {
17+
window.scrollTo({ top: location.state.scrollY ?? 0, behavior: 'auto' });
18+
}
19+
}, []);
20+
1421
function handleClose() {
22+
const scrollY = location.state?.scrollY;
23+
1524
if (location.state?.fromAbout) {
1625
history.push('/about');
26+
27+
setTimeout(() => {
28+
if (scrollY !== undefined) {
29+
window.scrollTo({ top: scrollY, behavior: 'auto' });
30+
}
31+
}, 0);
1732
} else {
1833
history.goBack();
1934
}
@@ -25,8 +40,11 @@ export default function LargePortraitCardPage() {
2540
path="/about/:completeName"
2641
render={({ history, match }) => {
2742
const { completeName } = match.params;
43+
console.log('name:', completeName)
2844
const teamMembers = getTeamByPersonName(completeName);
29-
const person = teamMembers.find(person => person.completeName.replace(/\s+/g, '') === completeName);
45+
console.log('members:', teamMembers)
46+
const person = teamMembers.find((person) => person.completeName.replace(/\s+/g, '').normalize("NFD").replace(/[\u0300-\u036f]/g, '') === completeName);
47+
console.log('Person:', person)
3048
if (!person) return null;
3149

3250
return (

src/components/about/SmallPortraitCard.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import styles from "./styles.module.css";
22
import { useHistory } from "@docusaurus/router";
33
import Avatar from "./Avatar";
44

5-
export function SmallPortraitCard({ person}) {
5+
export function SmallPortraitCard({ person }) {
66
const history = useHistory();
77

88
function openDialog() {
9+
let completeName = person.completeName.replace(/\s+/g, '');
10+
const completeNameWithoutAccents = completeName
11+
.normalize("NFD")
12+
.replace(/[\u0300-\u036f]/g, '');
13+
console.log('completeName:', completeNameWithoutAccents);
914
history.push({
10-
pathname: `/about/${person.completeName.replace(/\s+/g, '')}`,
11-
state: { fromAbout: true },
15+
pathname: `/about/${completeNameWithoutAccents}`,
16+
state: { fromAbout: true, scrollY: window.scrollY, },
1217
});
1318
}
1419

src/components/about/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import LinkToContact from "../home/LinkToContact";
66

77
export function getTeamByPersonName(name: string) {
88
for (const [teamName, members] of Object.entries(teams)) {
9-
const person = members.find((person) => person.completeName.replace(/\s+/g, '') === name);
9+
const person = members.find((person) => person.completeName.replace(/\s+/g, '').replace(/\s+/g, '').normalize("NFD").replace(/[\u0300-\u036f]/g, '') === name);
1010
if (person) {
1111
return members;
1212
}
File renamed without changes.

0 commit comments

Comments
 (0)