Problem with LazyColumn and clickable modifier
Majostik opened this issue · comments
Arsalan Bastuev commented
Hi
There is a problem with LazyColumn
and clickable
modifier, if I add clickable
to item of LazyColumn
then KLazyListItemNode
can't find child.
For example I modified your sample and tried to run
@Composable
private fun ListItemHeader(item: LazyListItem.Header, modifier: Modifier = Modifier) {
Box(
modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
.clickable { }
.clip(RoundedCornerShape(8.dp))
.background(Color.Green)
.then(modifier)
) {
Text(
item.title,
Modifier
.padding(8.dp)
.testTag("LazyListHeaderTitle")
)
}
}
I got error
java.lang.AssertionError: Failed to assert the following: (Text + EditableText = [Items from 1 to 10])
Can't retrieve node at index '0' of '(hasAnyAncestorThat(Semantics node id = 18)) && (TestTag = 'LazyListHeaderTitle')'
There are no existing nodes for that selector.
EvgenyMeltsaykin commented
Hi! Check that your nodes use the flag useUnmergedTree = true
This issue contains examples of how it can be configured
Arsalan Bastuev commented
Yeah, it's working. Can you please explain why it's now working without this flag?
EvgenyMeltsaykin commented
You can read more about it here