Skip to content

Bug in Range() implementation? #825

@rtrzebinski

Description

@rtrzebinski

Description:

I'm having a issue with the following code:

app.Range(h.rows).Slice(func(i int) app.UI {
  return &h.rows[i]
}),

It works fine when the component is loaded for the first time, but not when the slice and range needs to be updated.

On rebuilding the underlying slice with data from API call, the UI behaves incorrectly.

I tried manually running component.Update - did not help.

The only work around is reloading the page with ctx.Reload() but it's doing an ugly page refresh, and it's not a solution really.

Steps to reproduce:

git clone [email protected]:rtrzebinski/simple-memorizer-4.git
git checkout 58475e1c1171863229ff0de07d7f9dbb4c2c8bd4
make dev
make run
open http://localhost:8000/exercises

Add exercises: (question / answer):

11 / 11
22 / 22
33 / 33
44 / 44

(in order to retry with a fresh database simply run make dev && make run again and refresh the page)

Expected result:

Exercises will appear on the list as they are added.

No manual page reload is needed to display them properly.

Actual result:

Only 11 / 11 (first one added) keeps being duplicated, regardless of the following inputs:

Screen Shot 2023-04-02 at 06 59 29

Where is the code?

Range -> https://github.com/rtrzebinski/simple-memorizer-4/blob/58475e1c1171863229ff0de07d7f9dbb4c2c8bd4/internal/frontend/components/exercises.go#L40

Update trigger -> https://github.com/rtrzebinski/simple-memorizer-4/blob/58475e1c1171863229ff0de07d7f9dbb4c2c8bd4/internal/frontend/components/exercises.go#L71

Actual UI update -> https://github.com/rtrzebinski/simple-memorizer-4/blob/58475e1c1171863229ff0de07d7f9dbb4c2c8bd4/internal/frontend/components/exercises.go#L89

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions