shade icon indicating copy to clipboard operation
shade copied to clipboard

Client update is not triggered every time

Open Aivean opened this issue 4 years ago • 1 comments

Bug details

I've created a test project to test Shade with Ktor: https://github.com/Aivean/shade-ktor-test

However, on the TodoList example I've encountered weird behavior: items are not always added. I checked the onClick callback, it is called correctly every time. Also websocket log indicates that new correct state is send to the client after each click. However, state is not rendered on the client every time:

shade-bug

Note: I've added a delay to the onClick callback , with it it's much easier to reproduce the issue, but it also sporadically happens without the delay.

Steps to reproduce

  1. checkout https://github.com/Aivean/shade-ktor-test
  2. run ./gradlew run
  3. open http://localhost:8080/
  4. click Add button repeatedly multiple times
  5. observe view (not) updating

P.S. Thanks for creating this wonderful project.

Aivean avatar Feb 13 '21 02:02 Aivean

Aaa! I didn't realize anyone was using this project and Github didn't notify me that this issue was opened, so I just now actually saw it. Ten months later, I think the issue may have to do with how the TODO list items are defined:

todoList.forEach { item ->
            div {
                key = item
                +"TODO: "
                +item
            }
        }

In your example, the key given to each item is its text; so all of the "a" will have the same key. This is a wrong way to use keys, but Shade's handling should be more graceful nonetheless.

ScottPeterJohnson avatar Dec 02 '21 10:12 ScottPeterJohnson