react-grid-dnd icon indicating copy to clipboard operation
react-grid-dnd copied to clipboard

2.1.2 GridItem className not set

Open rsmarsh opened this issue 5 years ago • 1 comments

In 2.1.2 the className which is added to each GridItem, along with 'dragging' or 'disabled' is no longer functioning due to a jumbled ternary

This can be seen by taking the codesandbox demo from this repo's README, and bumping the react-grid-dnd version number up to 2.1.2, then inspect the div element wrapping each grid item (as seen here). You will see that the div now has a className of 'undefined', and when dragging, the 'dragging' class is not appended image

I have created a pull request #28 with an example fix for this.

rsmarsh avatar Dec 15 '20 09:12 rsmarsh

Issue is still present, easy to fix you need to add parenthesis because className conditional statement clears out content that is added before it. GridItem.tsx line 143

className:
      "GridItem" +
      (isDragging ? " dragging" : "") +
      (!!disableDrag ? " disabled" : "") +
      (className
        ? ` ${className}`
        : ""),

I can create PR

loocuu avatar Apr 11 '22 12:04 loocuu