Hi All. I'm looking to understand why, between co...
# compose
m
Hi All. I'm looking to understand why, between compose 1.7 and 1.9, the AnimatedVisibility composable is adding an intermediate node to the tree (judging by the node ids, i assume it's there, just not shown by the tree printing functions). For the following function:
Copy code
@RunWith(AndroidJUnit4::class)
class AnimatedVisibilityTest {
    @get:Rule
    val rule = createComposeRule()

    @Test
    fun testStructure() {
        rule.setContent {
            Column {
                Text("Header")
                AnimatedVisibility(visible = true) {
                    Text("Body")
                }
            }
        }
        println(rule.onRoot().printToString())

    }
}
On 1.7, i'd get this:
Copy code
Node #1 at (l=0.0, t=0.0, r=6.0, b=70.0)px
 |-Node #3 at (l=0.0, t=0.0, r=6.0, b=35.0)px
 | Text = '[Header]'
 | Actions = [SetTextSubstitution, ShowTextSubstitution, ClearTextSubstitution, GetTextLayoutResult]
 |-Node #5 at (l=0.0, t=35.0, r=4.0, b=70.0)px
   Text = '[Body]'
   Actions = [SetTextSubstitution, ShowTextSubstitution, ClearTextSubstitution, GetTextLayoutResult]
And i get this in 1.9 (notice the extra node, node #4):
Copy code
Node #1 at (l=0.0, t=0.0, r=6.0, b=70.0)px
 |-Node #3 at (l=0.0, t=0.0, r=6.0, b=35.0)px
 | Text = '[Header]'
 | Actions = [ClearTextSubstitution, GetTextLayoutResult, SetTextSubstitution, ShowTextSubstitution]
 |-Node #4 at (l=0.0, t=35.0, r=4.0, b=70.0)px
    |-Node #5 at (l=0.0, t=35.0, r=4.0, b=70.0)px
      Text = '[Body]'
      Actions = [ClearTextSubstitution, GetTextLayoutResult, SetTextSubstitution, ShowTextSubstitution]
I have also tried using an unmerged tree on 1.7, but that node #4 is not there, even then. This is affecting how i write my test fixtures, so i'm curious what changed that's causing this.
m
Except that AnimatedVisibility doesn't use either of those modifiers that i can tell. Which is why i was confused about why there's a node being inserted.
m
Thanks @Kirill Grouchnikov