Skip to content

Clearing autoShapes by passing an empty array not working #40

@aaronb97

Description

@aaronb97

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions