Is there a way to emit an element that is ignored ...
# compose
a
Is there a way to emit an element that is ignored for the purposes of layout?
e
Copy code
Modifier.size(0.dp).wrapContentSize(unbounded = true)
(untested, but I think something like that may work)
a
Unfortunately that’s not ignored. It’s just 0x0
If you add it to a
Column(verticalArrangement = Arrangement.spacedBy(100.dp)
you will definitely see its effect.
It probably doesn’t exist, but I was hoping maybe there’s some modifier you can tag the element with.
i
a
Funny you should mention
Popup
. The reason for this question is me trying to address this issue: https://github.com/JetBrains/compose-multiplatform/issues/2729 But looking at the Android code, it seems to suffer from the same problem, because
AndroidPopup
emits the same empty layout whose purpose is to get the parent’s position: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]android.kt;drc=82abb7ed0792545abb32c5a3ae7a12051aed1556;l=309
Confirmed that Android has the same bug.
e
hmm. popup position is based on position in the layout, and I don't see a way to get that without being laid out, which will have that spacing effect in row/column
a
Need something like
LocalCoordinates
e
how would that work?
Copy code
Layout(content = {
    Foo()
    LocalCoordinates
    Bar()
}, measurePolicy = { measureables, constraints ->
    // custom code
I don't think you can observe the coordinates it would be laid out at, without potentially affecting layout
a
It could work like onGloballyPoisitioned, but without the actual node
Maybe like ‘LocalCoordsProvider.current.onLocalCoordinates{ }`
m
Why cant you create a composable wrapper with an of else and your ignore condition there?