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

[bug] Whenever I click item, The order of the list does not change, and the setlist event will be triggered, which is not in line with the expectation. #200

Open
tianfeng65 opened this issue Jan 15, 2021 · 2 comments

Comments

@tianfeng65
Copy link

tianfeng65 commented Jan 15, 2021

Describe the bug

Whenever I click item, I just click. The order of the list does not change, and the setlist event will be triggered, which is not in line with the expectation.[bug]

Expected behavior
Only trigger setList when the order changes

@tianfeng65 tianfeng65 changed the title Whenever I click item, I just click. The order of the list does not change, and the setlist event will be triggered, which is not in line with the expectation.[bug] [bug] Whenever I click item, The order of the list does not change, and the setlist event will be triggered, which is not in line with the expectation. Jan 15, 2021
@baquiax
Copy link

baquiax commented Feb 18, 2021

@tianfeng65 I think it's because the library change the list when you click on one of the children.

e.g
If your list start like this

[{}, {}]

The library add some properties to your objects

[{"chosen":false,"selected":false},{"chosen":false,"selected":false}]

Then if you click on the first element of the grid, the underlying list will change meanwhile you are clicking the element

[{"chosen":true,"selected":false},{"chosen":false,"selected":false}]

Once you release the click you underlying list will change to:

[{"chosen":false,"selected":false},{"chosen":false,"selected":false}]

So this change of chosen is causing the update on the underlying list .

@baquiax
Copy link

baquiax commented Feb 18, 2021

I way I solved this was handling the extra parameters that the setList callback returns

setList={(newItems, _, { dragging }) => {
       // Dragging element is only present if you dragged an item, if it is a click it is null
        if (!dragging) {
          return;
        }

        setList(newItems);
}}

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

2 participants