I am new to Compose, and trying to implement a mas...
# compose-desktop
g
I am new to Compose, and trying to implement a master-detail type interface that is exhibiting inconsistent behavior. I am hoping someone can tell me what I am doing wrong, or if there is a bug. Things work as expected if the selected item in the master list is not changed. But once the selected master item is changed, it is no longer possible to edit fields in the detail view. I have uploaded a code sample here: https://gist.github.com/gsteckman/bbfb046673504935388a6eafc9eb652b. I would really appreciate any insights, especially if I am doing something in an incorrect or sub-optimal way for using compose.
i
Try to change to this:
Copy code
fun ItemForm(item: Item, saveAction: (Item) -> Unit) = key(item) {
Because
item
is changed we need to recreate all components that depends on it. Without
key
they will not be recreated (because they depends only on
tempItem.name
which is not changed). So
onValueChange
will not be changed (and
onValueChange
will modify the old captured
tempItem
)
g
Thanks! I was also able to replace "remember(item)" with just "remember", without the v1 parameter, and it still works.