Skip to content

Copies are added after quickly dragging elements in the subgrid #2560

Closed
Samg217/glpi
#8

Description

@v1talii-dev

If you quickly drag elements between nested blocks, duplicates of the same element appear.

Your environment

  • Gridstack 10.0.0
  • Chrome 119.0.6045.200/Windows 11

Steps to reproduce

  • We set up two nested grids as in the screenshot. Number of elements on the first level = 1.
    image

  • Quickly drag the element “1” to the area outside the nested block. After several repetitions, the number of elements on the first level is already 19. And as you can see in the screenshot, id="1" is duplicated.
    image

  • Reproduce on jsfiddle - https://jsfiddle.net/ironvd/54t6hnr1/60/

screencast-jsfiddle.net-2023.12.06-19_01_46.mp4

Expected behavior

The number of elements on the first level does not change after quick dragging

Activity

  1. v1talii-dev commented on Dec 7, 2023

    @v1talii-dev
    ContributorAuthor

    I roughly figured out the cause of the bug: at the dragging stage, an engine method is called, which adds a pseudo node to draw the future place for insertion. If you quickly move the mouse, a situation arises when nodes are added to the engine that should not be there. When a pseudo element is deleted, another method restores the original nodes, and there are duplicates in the original nodes. That is, the reason is the false filling of the original nodes.

    https://github.com/gridstack/gridstack.js/blob/master/src/gridstack.ts#L2038

  2. v1talii-dev commented on Dec 12, 2023

    @v1talii-dev
    ContributorAuthor

    I think I managed to solve the problem. As you can see in pr, when quickly dragging, node does not appear:
    image

    And I don’t delete gridstackNode so that the engine’s addNode method works correctly and the duplicate is detected correctly.
    image

  3. added 2 commits that reference this issue on Jan 15, 2024
    164f6b6
    e7fae47
  4. added a commit that references this issue on Jan 28, 2024
    3ea8fbe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions