Skip to content

Clear shapes patches#358

Open
johndoknjas wants to merge 7 commits intolichess-org:masterfrom
johndoknjas:clear-shapes-patches
Open

Clear shapes patches#358
johndoknjas wants to merge 7 commits intolichess-org:masterfrom
johndoknjas:clear-shapes-patches

Conversation

@johndoknjas
Copy link
Contributor

This PR does the following:

  • Renames the 'erase' property (again).
  • If said property is true, ensure the behaviour doesn't change. For example, in a live game, a mouchdown anywhere will clear all drawings.
  • Otherwise, clear arrows if the user clicks on a non-movable square, and then drags by a distance of at least 15px. This increases the requirement from the original PR, where all drawings would be cleared on any position change.

An outstanding concern of mine is whether clicking off the board and then back on it works properly. From personal experience yesterday, I noticed this was a bit glitchy. E.g., I think I had clicked off the board, and then after trying to click back on it a few times, the ctrl-z function (to clear drawings) didn't work. I'm not sure if anyone has insight into whether this PR would affect this, but just wanted to mention it.

If we merge this, we should probably close all issues made in chessground and lila, so that in case anyone still experiences bugs, they don't feel they'd be making a duplicate issue.

drawClear(s);
if (!previouslySelected && s.drawable.enabled) {
if (s.drawable.eraseOnMouchDown) drawClear(s);
else if (piece?.color !== s.turnColor) s.pixelCoordsOfMouchDownToMaybeClearShapes = position;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this turnColor check really only makes sense when you're playing a game. But most arrows I think are drawn in studies/broadcast/analysis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ornicar I've tested on studies/analysis and the turnColor stores which side is to move there as well. Unless I'm misunderstanding.

@ornicar
Copy link
Collaborator

ornicar commented Oct 22, 2025

Excuse me, but can you remind exactly what use case this improves?

I added a test board to experiment with it.

I think it works? But I don't understand why it's useful. I only found it more confusing, and harder to predict if a click or a drag will clear the shapes or not.

@johndoknjas
Copy link
Contributor Author

@ornicar Two main use cases I had in mind:

  • If the user is drawing arrows on a computer with their trackpad. I teach chess using lichess studies, and it's not uncommon for me to try to draw an arrow but to inadvertently left click and clear all the drawings. At time this happens repeatedly for some reason.
  • On a phone, any touch on the board (e.g., if the user's trying to scroll down or back up) erases all arrows, and then there's not even an option to ctrl+z it atm. Earlier this month I had to use my phone to review some openings before a tournament game, and I probably cleared around a dozen positions.

If the user's on a computer using a mouse though, I agree there're essentially no benefits.

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