Skip to content

Commit 3baf080

Browse files
fix: disable scroll in analysis modals + open lichess in new tab
1 parent a1a17dc commit 3baf080

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/components/Analysis/AnalysisConfigModal.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react'
1+
import React, { useState, useEffect } from 'react'
22
import { motion } from 'framer-motion'
33

44
interface Props {
@@ -16,6 +16,18 @@ export const AnalysisConfigModal: React.FC<Props> = ({
1616
}) => {
1717
const [selectedDepth, setSelectedDepth] = useState(initialDepth)
1818

19+
useEffect(() => {
20+
if (isOpen) {
21+
document.body.style.overflow = 'hidden'
22+
} else {
23+
document.body.style.overflow = 'unset'
24+
}
25+
26+
return () => {
27+
document.body.style.overflow = 'unset'
28+
}
29+
}, [isOpen])
30+
1931
const depthOptions = [
2032
{
2133
value: 12,

src/components/Analysis/AnalysisProgressOverlay.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import React, { useEffect } from 'react'
22
import { motion } from 'framer-motion'
33
import { GameAnalysisProgress } from 'src/hooks/useAnalysisController/useAnalysisController'
44

@@ -16,6 +16,18 @@ export const AnalysisProgressOverlay: React.FC<Props> = ({
1616
? Math.round((progress.currentMoveIndex / progress.totalMoves) * 100)
1717
: 0
1818

19+
useEffect(() => {
20+
if (progress.isAnalyzing) {
21+
document.body.style.overflow = 'hidden'
22+
} else {
23+
document.body.style.overflow = 'unset'
24+
}
25+
26+
return () => {
27+
document.body.style.overflow = 'unset'
28+
}
29+
}, [progress.isAnalyzing])
30+
1931
if (!progress.isAnalyzing) return null
2032

2133
return (

src/pages/profile/[name].tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ const Profile: React.FC<Props> = (props: Props) => {
157157
<div className="flex flex-col">
158158
<h1 className="text-3xl font-semibold">{props.name}</h1>
159159
<a
160+
target="_blank"
160161
href={`https://lichess.org/@/${props.name}`}
161162
className="text-sm text-primary"
162163
>

0 commit comments

Comments
 (0)