The problem is when the Boolean Property changes, the UI only updates when the element is no longer visible on the screen (in this case, when the user scrolls horizontally and the button leaves the page, when scrolling back to the button selected, it now shows highlighted, and the previously highlighted button is no longer highlighted)
Photo’s 1 - 3 show this behavior. ‘All’ is the default filter. On Screen One, ‘Title’ is selected. the user must drag the element out of view (screen two) and then coming back to the left most side of the row (screen three) you can see that the UI has shown this change.
Why does the Lazy Row only show this update when the user scrolls the element out of view?
I am using a lazy Row, and passing in a list where each element in the list is a data class (name : String, isSelected : False). I am using the isSelected property to style the button in the UI
each button has a callback function, which calls a function to iterate over the list I use for the Lazy Row, finds the element, and toggles that elements isSelected property to true.
Here is the code I use for this. A data class with two params, and a list of these that I use to pass into the lazyRow. I have a callback that each button calls when clicked, which finds the clicked element, and changes the state of that element (which is what I thought would trigger a re-render of the LazyRow, as this is the list that the LazyRow is rendering)
Finally, here is the lazyRow, how it’s called, the parameters and the Composable it renders for each element of the list.
I am a few months into my first software job, so any advice is greatly appreciated. I hope this question is clear and concise!