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

Drag and Drop Causes Flashing and Disappearing Cards #6001

Closed
Bonapara opened this issue Jun 24, 2024 · 5 comments · Fixed by #6065
Closed

Drag and Drop Causes Flashing and Disappearing Cards #6001

Bonapara opened this issue Jun 24, 2024 · 5 comments · Fixed by #6065
Assignees
Labels
good first issue Good for newcomers scope: front Issues that are affecting the frontend side only size: short

Comments

@Bonapara
Copy link
Member

Current Behavior

  1. I grab the "Twitch" card.
    CleanShot 2024-06-24 at 15 35 31

  2. I drag the card between "VMware" and "HP." The "Twitch" card disappears from the right column.
    CleanShot 2024-06-24 at 15 33 50

  3. When I release the click, the card is added to the left column but is displayed again in the right column.
    CleanShot 2024-06-24 at 15 37 42

  4. The card disappears from the left column, even though we want to drag it there.
    CleanShot 2024-06-24 at 15 38 58

  5. The card disappears from the right column and finally appears in the left column.
    CleanShot 2024-06-24 at 15 40 03

Full Behavior in Video:

CleanShot.2024-06-24.at.15.31.13.mp4

Desired Behavior

Prevent any flashing when dragging and dropping a card to another column.

@Bonapara Bonapara added good first issue Good for newcomers scope: front Issues that are affecting the frontend side only size: short labels Jun 24, 2024
Copy link
Contributor

greptile-apps bot commented Jun 24, 2024

To resolve the flashing and disappearing cards issue during drag-and-drop, follow these steps:

  1. Locate Drag-and-Drop Handling:

    • RecordBoard component: frontend/src/components/RecordBoard/RecordBoard.tsx
    • RecordBoardColumnCardsContainer component: frontend/src/components/RecordBoard/RecordBoardColumnCardsContainer.tsx
  2. Update State Management:

    • Ensure the state updates correctly during the drag-and-drop lifecycle. Specifically, check the onDragStart, onDragOver, onDrop, and onDragEnd handlers.
  3. Modify RecordBoard.tsx:

    • Ensure the card being dragged is properly managed. Example:
      const handleDragStart = (event, cardId) => {
        event.dataTransfer.setData('cardId', cardId);
        setDraggingCardId(cardId);
      };
      const handleDrop = (event, columnId) => {
        const cardId = event.dataTransfer.getData('cardId');
        // Update state to reflect card movement
        moveCardToColumn(cardId, columnId);
        setDraggingCardId(null);
      };
  4. Modify RecordBoardColumnCardsContainer.tsx:

    • Ensure the card is rendered correctly during drag-and-drop. Example:
      const RecordBoardColumnCardsContainer = ({ columnId, cards }) => {
        return (
          <div onDrop={(e) => handleDrop(e, columnId)} onDragOver={(e) => e.preventDefault()}>
            {cards.map(card => (
              <Card key={card.id} card={card} draggable onDragStart={(e) => handleDragStart(e, card.id)} />
            ))}
          </div>
        );
      };
  5. Ensure Consistent State:

    • Verify that the state reflects the card's position accurately throughout the drag-and-drop process to prevent flashing and disappearing issues.

References

@rksingh2001
Copy link
Contributor

Can I get assigned to this issue?

@Bonapara
Copy link
Member Author

Sure @rksingh2001, thanks for contributing!

@rksingh2001
Copy link
Contributor

@Bonapara I think you forgot to assign me :)

@Bonapara
Copy link
Member Author

done, Sorry 😅

rksingh2001 added a commit to rksingh2001/twenty that referenced this issue Jun 27, 2024
lucasbordeau added a commit to rksingh2001/twenty that referenced this issue Aug 12, 2024
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Product development ✅ Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers scope: front Issues that are affecting the frontend side only size: short
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants