Good morning all. I am trying to upgrade from com...
# compose
m
Good morning all. I am trying to upgrade from compose 1.7 to 1.10 (bom 2026.04.00). I have a matcher like this that i use to some complex matching that can't be done directly with onChildren. Basically i want to match something and also check to see if it's got a specific node in it's parent tree.
Copy code
/***
 * Returns a matcher that matches if the node has any ancestor matching the
 * given interaction's node id.
 */
fun hasAnyAncestorNode(interaction: SemanticsNodeInteraction) = hasAnyAncestor(
    SemanticsMatcher("hasAnyAncestorNode: ${interaction}") { node ->
        node.id == interaction.fetchSemanticsNode().id
    }
)
And example usage is looking for the "picker" node on a material DatePicker:
Copy code
interactionProvider.onNode(
                hasTestTag("picker").and(hasAnyAncestorNode(interaction))
            )
However, i'm running into this error when it executes fetchSemanticsNode:
Copy code
java.lang.IllegalStateException: Functions that involve synchronization (Assertions, Actions, Synchronization; e.g. assertIsSelected(), doClick(), runOnIdle()) cannot be run from the main thread. Did you nest such a function inside runOnIdle {}, runOnUiThread {} or setContent {}?
I'm wondering what the right way is to update this for compose 1.10
s
pass id as a parameter to this function, that should do the trick
m
yeah, that's what i ended up settling on.
Copy code
hasAnyAncester(hasNodeId(interaction.fetchSemanticsNode().id))
hasNodeId
is a pretty simple matcher.