Skip to content

Conversation

@johndoknjas
Copy link
Contributor

@johndoknjas johndoknjas commented Nov 26, 2024

Currently, pressing the 'starting position' button will always give the standard starting position in the editor, regardless of the variant selected. E.g.:

image

This PR makes it so that the rules are updated when a new variant is selected. This is useful when then pressing the 'starting position' button for racing kings, horde, and antichess (no castling rights).

@johndoknjas johndoknjas marked this pull request as draft November 26, 2024 10:52
@johndoknjas johndoknjas marked this pull request as ready for review November 26, 2024 12:00
const triggerChange = () =>
ctrl.editor
? selectEl.dispatchEvent(new Event('change'))
: setTimeout(triggerChange, 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm that doesn't look very good. Could there be a better way?

@ornicar
Copy link
Collaborator

ornicar commented Nov 26, 2024

The new code is a bit of a hack, its purpose is not obvious. I'll argue that it adds too much complexity for the relatively rare use case that it covers.

Can the editor be instantiated with the correct rules right away, instead?

@johndoknjas
Copy link
Contributor Author

@ornicar Updated to set the rules directly after the editor is made, without needing the insert hack.

@ornicar ornicar merged commit 7adf2f8 into lichess-org:master Nov 27, 2024
3 checks 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.

2 participants