@@ -15,6 +15,7 @@ interface AnalysisProps {
1515 showAnnotations ?: boolean
1616 showVariations ?: boolean
1717 disableKeyboardNavigation ?: boolean
18+ disableMoveClicking ?: boolean
1819}
1920
2021interface TuringProps {
@@ -25,6 +26,7 @@ interface TuringProps {
2526 showAnnotations ?: boolean
2627 showVariations ?: boolean
2728 disableKeyboardNavigation ?: boolean
29+ disableMoveClicking ?: boolean
2830}
2931
3032interface PlayProps {
@@ -35,6 +37,7 @@ interface PlayProps {
3537 showAnnotations ?: boolean
3638 showVariations ?: boolean
3739 disableKeyboardNavigation ?: boolean
40+ disableMoveClicking ?: boolean
3841}
3942
4043type Props = AnalysisProps | TuringProps | PlayProps
@@ -70,6 +73,7 @@ export const MovesContainer: React.FC<Props> = (props) => {
7073 showAnnotations = true ,
7174 showVariations = true ,
7275 disableKeyboardNavigation = false ,
76+ disableMoveClicking = false ,
7377 } = props
7478 const { isMobile } = useContext ( WindowSizeContext )
7579 const containerRef = useRef < HTMLDivElement > ( null )
@@ -224,9 +228,11 @@ export const MovesContainer: React.FC<Props> = (props) => {
224228 ? currentMoveRef
225229 : null
226230 }
227- onClick = { ( ) =>
228- baseController . goToNode ( pair . whiteMove as GameNode )
229- }
231+ onClick = { ( ) => {
232+ if ( ! disableMoveClicking ) {
233+ baseController . goToNode ( pair . whiteMove as GameNode )
234+ }
235+ } }
230236 className = { `flex min-w-fit cursor-pointer flex-row items-center rounded px-2 py-1 text-sm ${
231237 baseController . currentNode === pair . whiteMove
232238 ? 'bg-human-4/20'
@@ -262,9 +268,11 @@ export const MovesContainer: React.FC<Props> = (props) => {
262268 ? currentMoveRef
263269 : null
264270 }
265- onClick = { ( ) =>
266- baseController . goToNode ( pair . blackMove as GameNode )
267- }
271+ onClick = { ( ) => {
272+ if ( ! disableMoveClicking ) {
273+ baseController . goToNode ( pair . blackMove as GameNode )
274+ }
275+ } }
268276 className = { `flex min-w-fit cursor-pointer flex-row items-center rounded px-2 py-1 text-sm ${
269277 baseController . currentNode === pair . blackMove
270278 ? 'bg-human-4/20'
@@ -298,9 +306,13 @@ export const MovesContainer: React.FC<Props> = (props) => {
298306 { termination && (
299307 < div
300308 className = "min-w-fit cursor-pointer border border-primary/10 bg-background-1/90 px-4 py-1 text-sm opacity-90"
301- onClick = { ( ) =>
302- baseController . goToNode ( mainLineNodes [ mainLineNodes . length - 1 ] )
303- }
309+ onClick = { ( ) => {
310+ if ( ! disableMoveClicking ) {
311+ baseController . goToNode (
312+ mainLineNodes [ mainLineNodes . length - 1 ] ,
313+ )
314+ }
315+ } }
304316 >
305317 { termination . result }
306318 { ', ' }
@@ -330,7 +342,9 @@ export const MovesContainer: React.FC<Props> = (props) => {
330342 baseController . currentNode === whiteNode ? currentMoveRef : null
331343 }
332344 onClick = { ( ) => {
333- if ( whiteNode ) baseController . goToNode ( whiteNode )
345+ if ( whiteNode && ! disableMoveClicking ) {
346+ baseController . goToNode ( whiteNode )
347+ }
334348 } }
335349 data-index = { index * 2 + 1 }
336350 className = { `col-span-2 flex h-7 flex-1 cursor-pointer flex-row items-center justify-between px-2 text-sm hover:bg-background-2 ${ baseController . currentNode === whiteNode && 'bg-human-4/10' } ${ highlightSet . has ( index * 2 + 1 ) && 'bg-human-3/80' } ` }
@@ -363,14 +377,17 @@ export const MovesContainer: React.FC<Props> = (props) => {
363377 currentNode = { baseController . currentNode }
364378 goToNode = { baseController . goToNode }
365379 showAnnotations = { showAnnotations }
380+ disableMoveClicking = { disableMoveClicking }
366381 />
367382 ) : null }
368383 < div
369384 ref = {
370385 baseController . currentNode === blackNode ? currentMoveRef : null
371386 }
372387 onClick = { ( ) => {
373- if ( blackNode ) baseController . goToNode ( blackNode )
388+ if ( blackNode && ! disableMoveClicking ) {
389+ baseController . goToNode ( blackNode )
390+ }
374391 } }
375392 data-index = { index * 2 + 2 }
376393 className = { `col-span-2 flex h-7 flex-1 cursor-pointer flex-row items-center justify-between px-2 text-sm hover:bg-background-2 ${ baseController . currentNode === blackNode && 'bg-human-4/10' } ${ highlightSet . has ( index * 2 + 2 ) && 'bg-human-3/80' } ` }
@@ -403,6 +420,7 @@ export const MovesContainer: React.FC<Props> = (props) => {
403420 currentNode = { baseController . currentNode }
404421 goToNode = { baseController . goToNode }
405422 showAnnotations = { showAnnotations }
423+ disableMoveClicking = { disableMoveClicking }
406424 />
407425 ) : null }
408426 </ >
@@ -411,9 +429,11 @@ export const MovesContainer: React.FC<Props> = (props) => {
411429 { termination && ! isMobile && (
412430 < div
413431 className = "col-span-5 cursor-pointer rounded-sm border border-primary/10 bg-background-1/90 p-5 text-center opacity-90"
414- onClick = { ( ) =>
415- baseController . goToNode ( mainLineNodes [ mainLineNodes . length - 1 ] )
416- }
432+ onClick = { ( ) => {
433+ if ( ! disableMoveClicking ) {
434+ baseController . goToNode ( mainLineNodes [ mainLineNodes . length - 1 ] )
435+ }
436+ } }
417437 >
418438 { termination . result }
419439 { ', ' }
@@ -432,12 +452,14 @@ function FirstVariation({
432452 currentNode,
433453 goToNode,
434454 showAnnotations,
455+ disableMoveClicking = false ,
435456} : {
436457 node : GameNode
437458 color : 'white' | 'black'
438459 currentNode : GameNode | undefined
439460 goToNode : ( node : GameNode ) => void
440461 showAnnotations : boolean
462+ disableMoveClicking ?: boolean
441463} ) {
442464 return (
443465 < >
@@ -452,6 +474,7 @@ function FirstVariation({
452474 goToNode = { goToNode }
453475 level = { 0 }
454476 showAnnotations = { showAnnotations }
477+ disableMoveClicking = { disableMoveClicking }
455478 />
456479 ) ) }
457480 </ ul >
@@ -487,7 +510,11 @@ function VariationTree({
487510 return (
488511 < li className = { `tree-li ${ level === 0 ? 'no-tree-connector' : '' } ` } >
489512 < span
490- onClick = { ( ) => goToNode ( node ) }
513+ onClick = { ( ) => {
514+ if ( ! disableMoveClicking ) {
515+ goToNode ( node )
516+ }
517+ } }
491518 className = { `cursor-pointer px-0.5 text-xs ${
492519 currentNode ?. fen === node ?. fen
493520 ? 'rounded bg-human-4/20 text-primary'
@@ -520,6 +547,7 @@ function VariationTree({
520547 goToNode = { goToNode }
521548 level = { level }
522549 showAnnotations = { showAnnotations }
550+ disableMoveClicking = { disableMoveClicking }
523551 />
524552 </ span >
525553 ) : variations . length > 1 ? (
@@ -532,6 +560,7 @@ function VariationTree({
532560 goToNode = { goToNode }
533561 level = { level + 1 }
534562 showAnnotations = { showAnnotations }
563+ disableMoveClicking = { disableMoveClicking }
535564 />
536565 ) ) }
537566 </ ul >
@@ -577,7 +606,11 @@ function InlineChain({
577606 { chain . map ( ( child ) => (
578607 < Fragment key = { child . move } >
579608 < span
580- onClick = { ( ) => goToNode ( child ) }
609+ onClick = { ( ) => {
610+ if ( ! disableMoveClicking ) {
611+ goToNode ( child )
612+ }
613+ } }
581614 className = { `cursor-pointer px-0.5 text-xs ${
582615 currentNode ?. fen === child ?. fen
583616 ? 'rounded bg-human-4/50 text-primary'
@@ -617,6 +650,7 @@ function InlineChain({
617650 goToNode = { goToNode }
618651 level = { level + 1 }
619652 showAnnotations = { showAnnotations }
653+ disableMoveClicking = { disableMoveClicking }
620654 />
621655 ) ) }
622656 </ ul >
0 commit comments