franciscoBSalgueiro / en-croissant

The Ultimate Chess Toolkit

Home Page:https://encroissant.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Board position resets on toggle edit in certain circumstances

jez9999 opened this issue · comments

commented

Describe the bug

I've noticed the board position resetting on toggle edit in certain circumstances. I suspect it's to do with the following code:

useEffect(() => {
if (editingMode && boardFen && boardFen !== currentNode.fen) {
setFen(boardFen);
}
}, [boardFen, editingMode, setFen]);

Why boardFen gets out of sync with currentNode.fen I don't know.

Reproduction

  1. Open a new analysis board
  2. Toggle 'edit position' and move a piece
  3. Exit editing mode
  4. Run engine analysis
  5. Click on an engine analysis line
  6. Toggle 'edit position' again (board position resets to what it was before you clicked on the analysis line)

Platform and versions

Windows 10, version 0.10.0.

Stack trace

No response

commented

When the board position resets, it also erases the whole moves list. In fact, switching in and out of edit mode sometimes erases the whole moves list even when no edit is made, which also seems like a bug and is likely related to this bug. Oddly, that doesn't always happen and I can import a PGN, switch in and out of edit mode, and it retains the moves list correctly.

However, the moves list is erased when, for example, you:

  1. Import a PGN
  2. Move pieces to create a different continuation
  3. Switch in and out of edit mode

This should fix both problems