Skip to content

Commit f351e10

Browse files
fix: keep SAN move labels stable before stockfish colors load
1 parent c2949d3 commit f351e10

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/components/Analysis/Highlight.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ export const Highlight: React.FC<Props> = ({
512512
<p
513513
className={`text-left font-mono ${simplified ? 'text-sm' : 'text-sm md:text-xxs xl:text-xs'}`}
514514
>
515-
{move}
515+
{colorSanMapping[move]?.san ?? move}
516516
</p>
517517
<p
518518
className={`text-right font-mono ${simplified ? 'text-sm' : 'text-sm md:text-xxs xl:text-xs'}`}
@@ -620,7 +620,7 @@ export const Highlight: React.FC<Props> = ({
620620
<p
621621
className={`text-left font-mono ${simplified ? 'text-sm' : 'text-sm md:text-xxs xl:text-xs'}`}
622622
>
623-
{move}
623+
{colorSanMapping[move]?.san ?? move}
624624
</p>
625625
<p
626626
className={`text-right font-mono ${simplified ? 'text-sm' : 'text-sm md:text-xxs xl:text-xs'}`}

src/hooks/useAnalysisController/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ export const generateColorSanMapping = (
5656

5757
const chess = new Chess(fen)
5858
const moves = chess.moves({ verbose: true })
59+
moves.forEach((m) => {
60+
const moveKey = `${m.from}${m.to}${m.promotion || ''}`
61+
mapping[moveKey] = {
62+
san: m.san,
63+
color: '#FFF',
64+
}
65+
})
5966

6067
if (!stockfish) return mapping
6168

0 commit comments

Comments
 (0)