You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have a Vec inside a store (notes) and a DateTime inside another store (selected_note_date). I passed the notes to a For and in the for used the selected_note_date to set the selected item.
Now when I change the selected_note_date store and remove a note from the notes, it throws this error:
reading from a keyed field that has not yet been created
Additional context
If I don't set the new selected_note_date inside the match, it works.
If I don't remove the item from the notes (inside the retain method), it works.
If I don't get the child in the selected class (class:selected) , it works.
But If I do all three of them, the error happens.
The text was updated successfully, but these errors were encountered:
I added some logging and noticed that the class selectors are being triggered to change before the notes have been modified, so before the each prop is evaluated again.
If I move the two changes in delete_note so that the old note is deleted before the new selected note is set, it also works (?) Or at least does not panic.
Or, if I add something like a request_animation_frame around the selected_note.set so that it evaluates after the notes have been modified, that also works.
I'm not sure if one or the other of those fixes the issue for you. The example is a bit too complicated for me to easily wrap my head around what's actually causing the problem.
Sorry I missed a logical condition. the point of match is "If the deleting child is also selected, select another note" so I should wrap the match with this condition:
if selected_note_date.get().is_some_and(|it| it == child.date){match ...}
Due to the logic, the deletion should be after match.
And actually wrapping the deleting notes with request_animation_frame did the job, which is wired because it normally should run after setting selected note.
Describe the bug
I have a Vec inside a store (notes) and a DateTime inside another store (selected_note_date). I passed the notes to a For and in the for used the selected_note_date to set the selected item.
Now when I change the selected_note_date store and remove a note from the notes, it throws this error:
To Reproduce
This is the main part:
(Repo: https://github.com/mahdi739/leptos_notes_minirep/blob/main/src/main.rs)
Additional context
If I don't set the new selected_note_date inside the match, it works.
If I don't remove the item from the notes (inside the retain method), it works.
If I don't get the child in the selected class (class:selected) , it works.
But If I do all three of them, the error happens.
The text was updated successfully, but these errors were encountered: