-
-
Notifications
You must be signed in to change notification settings - Fork 421
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
Unable to sort a Collection
with @cycle/state
#937
Comments
I have the same issue. My hacky workaround has been to set the array to [] then immediately add the sorted items back to the array. It works, but becomes noticeable (flash of white screen) with large arrays. Would be nice to have a proper fix. |
The code sandbox does not really work for me, but I see the code does not use |
I might have this wrong, but I thought that's exactly what P.S. I don't know why the sandbox wouldn't work for you, sometimes it gets stuck for me as well and I just hit the refresh button on the |
I think I can reproduce the issue on CodeSandbox. I think the assumption is correct that this may be a bug in pickCombine, we may be missing a test case for simple reshuffling of the instances, such as what a sort does. |
I'm trying to render a list of
state.items
withmakeCollection
and I'm using a state lens where the getter sorts that list based on astate.sort
value and returns it.Clicking a "sort" button would update the
state.sort
value and the lens getter is invoked, creates a new list, sorts and then returns it, but the dom items are not reordered until the next update tostate.items
.After further investigating the issue, I found that
pickCombine
might be the culprit and changing these lines towould make it work, though I'm not sure about the implications and I don't know if it's introducing a memory leak.
Code to reproduce the issue:
Expected behavior:
Clicking the
Toggle sort
button would sort the list items inasc/desc/none
order.Actual behavior:
The DOM doesn't update until you add a new item.
Versions of packages used:
The text was updated successfully, but these errors were encountered: