https://kotlinlang.org logo
#compose
Title
# compose
f

florent

03/07/2021, 12:53 PM
Hi everyone, I did https://developer.android.com/codelabs/jetpack-compose-state?continue=https%3A%2F%2Fdev[…]2Fdeveloper.android.com%2Fcodelabs%2Fjetpack-compose-state yesterday and it doesn't work, I did the exercise step by step and also tried the finished version on my phone. When I try to edit and change the text, I can only type one letter, do you know how to fix that? Thanks!
here is a video of what's happening
d

Denis

03/07/2021, 12:55 PM
could you show the code of the input?
f

florent

03/07/2021, 12:59 PM
it is quite a lot of code and I am not really up to speed yet with compose so I don't know which part in particular isn't working, you can find all of it there https://github.com/googlecodelabs/android-compose-codelabs/blob/main/StateCodelab/finished/src/main/java/com/codelabs/state/todo/TodoScreen.kt
d

Denis

03/07/2021, 1:01 PM
what do your
onTextChange
and
onEditItemChange
look like?
f

florent

03/07/2021, 1:04 PM
Copy code
onTextChange = { onEditItemChange(item.copy(task = it)) }
and
Copy code
fun onEditItemChange(item: TodoItem) {
        val currentItem = requireNotNull(currentEditItem)
        require(currentItem.id == item.id) {
            "You can only change an item with the same id as currentEditItem"
        }

        todoItems = todoItems.toMutableList().also {
            it[currentEditPosition] = item
        }
    }
I have also tried with the finished module and I get the same result
d

Denis

03/07/2021, 1:10 PM
have you tried to debug it? for instance, is
it
what you'd expect it to be in
onTextChange
? (sorry for generic questions, can't load the project right now)
hi @florent, have you solved the issue?
f

florent

03/08/2021, 1:26 PM
👍 1
I don't have the time to look at it at the moment, I am just very interested by the solution
4 Views