Skip to content

feat(editor): implement separate function board clearing logic#3153

Merged
veloce merged 2 commits into
lichess-org:mainfrom
fahadahmed32:resolve-clear-board-not-working
May 12, 2026
Merged

feat(editor): implement separate function board clearing logic#3153
veloce merged 2 commits into
lichess-org:mainfrom
fahadahmed32:resolve-clear-board-not-working

Conversation

@fahadahmed32

Copy link
Copy Markdown

Summary
This PR fixes a bug in the Board Editor where the "Clear Board" action would fail or cause an invalid state. The previous implementation attempted to load an empty FEN string, which triggers Position.setupPosition validation. Since a valid chess position requires kings, the empty FEN was rejected, leading to crashes or the board not updating.

Changes
BoardEditorController: Added a dedicated clearBoard() method. This method bypasses FEN parsing and directly updates the state with an empty piece map and reset metadata (castling rights, en passant, etc.).
BoardEditorScreen: Updated the "Clear Board" bottom sheet action to call the new clearBoard() method instead of loadFen(kEmptyFEN).

@tom-anders

Copy link
Copy Markdown
Collaborator

Thanks for your contribution! It would be great if you could add a regression test to https://github.com/lichess-org/mobile/blob/main/test/view/board_editor/board_editor_screen_test.dart (i.e. a test that would fail without your commit)

@fahadahmed32

Copy link
Copy Markdown
Author

Thanks for your contribution! It would be great if you could add a regression test to https://github.com/lichess-org/mobile/blob/main/test/view/board_editor/board_editor_screen_test.dart (i.e. a test that would fail without your commit)

added

@veloce veloce left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@veloce veloce merged commit 7736cad into lichess-org:main May 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants