Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearing autoShapes by passing an empty array not working #40

Open
aaronb97 opened this issue Jan 31, 2021 · 2 comments
Open

Clearing autoShapes by passing an empty array not working #40

aaronb97 opened this issue Jan 31, 2021 · 2 comments

Comments

@aaronb97
Copy link

The issue is when setting autoShapes to an empty array like so after it is set to an array of length > 0, the change is not reflected in the underlying chessground module

Screen Shot 2021-01-31 at 11 13 08 AM

The crux of the problem is the merge function in config.ts in the chessground package merges the previous state and the current config (props). for const key in extend where extend is an empty array does nothing
Screen Shot 2021-01-31 at 11 11 08 AM

I was able to hack around this problem by patching the render function in react-chessground/chessground.js to include

if (this.cg && this.props.drawable && this.props.drawable.autoShapes) {
  this.cg.setAutoShapes(this.props.drawable.autoShapes);
}

I think there is probably a better way to fix this, but I am not that familiar with React. I think cg.setAutoShapes needs to be leveraged somehow

Screen Shot 2021-01-31 at 11 13 52 AM

@robert-j-webb
Copy link

robert-j-webb commented Feb 15, 2021

+1 to using the chessGround setAutoShapes here - I think just adding that API to the chessground wrapper should suffice. Going to make a fork that does that (mostly for my own use but I will send a pull request)

@jlambert23
Copy link

Upgrading to chessground v7.12.0 should solve this issue

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

No branches or pull requests

3 participants