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

Error in count of TodoMVC example #524

Closed
imjared opened this issue Aug 15, 2015 · 2 comments
Closed

Error in count of TodoMVC example #524

imjared opened this issue Aug 15, 2015 · 2 comments
Labels

Comments

@imjared
Copy link

imjared commented Aug 15, 2015

I'd love to send a PR for this one since I'm just getting my feet wet but it might take me a bit so I'll defer to people smarter :)

To reproduce:

  1. Load TodoMVC example
  2. Add a few items to your todo list. Note that the counter properly increments (mine is at 4)
  3. Mark one item as complete. Note that the counter properly decrements (mine is at 3)
  4. Toggle the view to show only completed tasks. Note the counter still correctly shows the number of items left on your list. (mine is at 3)
  5. Click "clear completed." You should still have the correct number of items displaying. (mine is at 3)
  6. Go back to the "all" view. Add a new item to the list.

Expected result:

  1. The list should grow in length with the item I just added at the top. The counter of "items left" should increment by one

Actual result

  1. My item is added to the top but the last item on the list disappears. The counter of "items left" has incremented by one but only three items are visible. image
  2. Adding new items after this will grow the list as expected but the Todo that disappeared will remain gone. The counter of "items left" still accounts for the missing Todo.

There's some additional funk on the counter that occurs if you remove an item from the list while it's in this incremented state. I can file more of a bug report if needed but I have a hunch that resolving this problem will resolve the latter issue.

@salehe
Copy link
Contributor

salehe commented Aug 15, 2015

This is happening because the newly added task has the same id as the previous task. This is because the todos reducer is simply assigning state.length as id when a new task is added.

I think the solution is to keep some increment-only part (like nextId) in the state or just use big UUIDs.

@gaearon gaearon added the bug label Aug 15, 2015
gaearon added a commit that referenced this issue Aug 15, 2015
Find next todo ID correctly. Fixes #524
@gaearon
Copy link
Contributor

gaearon commented Aug 15, 2015

Thanks a lot! Should be fixed in 1.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants