In Tutorial 3, deleting the currently selected item does not exit edit mode
avf opened this issue · comments
First of all, thank you for creating Behavior Graph, and also this amazing documentation. This library looks so damn awesome. After playing around with Elm, FRP (Sodium), and many other such libraries, I stumbled upon this in a very recent HN thread, and I'm extremely excited to try this out!
I found a small bug in the finished Tutorial 3, (also in the JSFiddle) here's how to repro:
- Add an item with any name
- Go into edit mode for that item
- Delete the item
- Edit mode should be exited, but instead we stay in edit mode for the deleted item, which is an inconsistent state
I think this can be fixed by modifying the behavior that .supplies(this.selected)
, by adding this.removeItem
to its demands
:
.demands(this.selectRequest, this.save, this.removeItem)
And also changing this else if
clause:
} else if (this.save.justUpdated) {
to:
} else if (this.save.justUpdated || (this.removeItem.justUpdated && this.removeItem.value === this.selected.value)) {
Sorry. Slow to getting to the documentation fixes. You are correct that it leaves selected
in the same state. I think your suggestion is a good one. I'll will work on getting this into the documentation and tutorial code.