mirror of
https://github.com/material-components/material-components-android.git
synced 2026-01-20 20:12:52 +08:00
There was a bug in the way the dependency graph was filled on the first measure/layout pass. We iterated over all child views and for each child A we iterated every other child and for each other child B we checked if B depends on A and if so, we added an edge A->B to the dependency graph. For anchors, on the first run, each child's LayoutParams only have info about its anchorId and not the anchor view itself. This is resolved by calling LayoutParams.findAnchorView(). Until this call, checking LayoutParams.dependsOn() returns false. In current implementation we only called findAnchorView() for child A, but then we checked dependsOn() for child B. This fixes this issue with inverting the check, so we check if A depends on B and if it does, we add an edge B->A to the dependency graph. Bug: 31622224 Test: Added CoordinatorLayoutTest.testAnchorDependencyGraph() test case that fails without this fix. Change-Id: Idcdf82031cce02340b2733aad1e30feb6f9359bb PiperOrigin-RevId: 177204145