Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d767a578 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz
Browse files

[Expandable] Add isAttached check in onGloballyPositioned

This change fixes a crash that can occur during an expandable animation.
There is a potential crash when onGloballyPositioned is called after a
composable has been detached or before it is attached from the UI
hierarchy. The fix adds a check to ensure the composable is still
attached before performing layout operations.

Bug: 405199654
Test: n/a because i couldn't reproduce the crash.
Flag: EXEMPT crash fix.
Change-Id: Ib5041f190d3326e9cba15126b60871f55a52fd27
parent 54951b09
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -311,7 +311,11 @@ fun Expandable(
                    .then(clickModifier(controller, onClick, onClickLabel, interactionSource))
                    .animatedBackground(color, shape = shape)
                    .border(controller)
                    .onGloballyPositioned { controller.boundsInComposeViewRoot = it.boundsInRoot() }
                    .onGloballyPositioned {
                        if (it.isAttached) {
                            controller.boundsInComposeViewRoot = it.boundsInRoot()
                        }
                    }
            ) {
                wrappedContent(controller.expandable)
            }