Fix clipped elevation in DropdownMenu
Fixes: 158803144
Test: MenuTest
Change-Id: I0af10d25ebe9e3ff19a001a514ce9ca3d7239419
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
index ed16c4a..650dd33 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
@@ -122,9 +122,9 @@
hasAnyChildThat(hasTestTag("MenuContent2"))
).assertExists().fetchSemanticsNode()
with(composeTestRule.density) {
- assertThat(node.size.width).isEqualTo(130 + MenuElevation.toIntPx() * 2)
+ assertThat(node.size.width).isEqualTo(130 + MenuElevationInset.toIntPx() * 2)
assertThat(node.size.height).isEqualTo(200 +
- DropdownMenuVerticalPadding.toIntPx() * 2 + MenuElevation.toIntPx() * 2
+ DropdownMenuVerticalPadding.toIntPx() * 2 + MenuElevationInset.toIntPx() * 2
)
}
}
@@ -140,7 +140,7 @@
}
val anchorPosition = IntOffset(100, 200)
val anchorSize = IntSize(10, 20)
- val inset = with(density) { MenuElevation.toIntPx() }
+ val inset = with(density) { MenuElevationInset.toIntPx() }
val offsetX = 20
val offsetY = 40
val popupSize = IntSize(50, 80)
@@ -194,7 +194,7 @@
val anchorPosition = IntOffset(450, 950)
val anchorPositionRtl = IntOffset(50, 950)
val anchorSize = IntSize(10, 20)
- val inset = with(density) { MenuElevation.toIntPx() }
+ val inset = with(density) { MenuElevationInset.toIntPx() }
val offsetX = 20
val offsetY = 40
val popupSize = IntSize(150, 80)
@@ -247,7 +247,7 @@
}
val anchorPosition = IntOffset(100, 200)
val anchorSize = IntSize(10, 20)
- val inset = with(density) { MenuElevation.toIntPx() }
+ val inset = with(density) { MenuElevationInset.toIntPx() }
val offsetX = 20
val offsetY = 40
val popupSize = IntSize(50, 80)
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Menu.kt b/ui/ui-material/src/main/java/androidx/ui/material/Menu.kt
index d6132e8..4c19528 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Menu.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Menu.kt
@@ -138,7 +138,7 @@
Card(
modifier = drawLayer
// Padding to account for the elevation, otherwise it is clipped.
- .padding(MenuElevation),
+ .padding(MenuElevationInset),
elevation = MenuElevation
) {
@OptIn(ExperimentalLayout::class)
@@ -200,18 +200,19 @@
}
// Size constants.
-internal val MenuElevation = 8.dp
-internal val DropdownMenuHorizontalPadding = 16.dp
+private val MenuElevation = 8.dp
+internal val MenuElevationInset = 16.dp
+private val DropdownMenuHorizontalPadding = 16.dp
internal val DropdownMenuVerticalPadding = 8.dp
-internal val DropdownMenuItemDefaultMinWidth = 112.dp
-internal val DropdownMenuItemDefaultMaxWidth = 280.dp
-internal val DropdownMenuItemDefaultMinHeight = 48.dp
+private val DropdownMenuItemDefaultMinWidth = 112.dp
+private val DropdownMenuItemDefaultMaxWidth = 280.dp
+private val DropdownMenuItemDefaultMinHeight = 48.dp
// Menu open/close animation.
private val Scale = FloatPropKey()
private val Alpha = FloatPropKey()
-internal val InTransitionDuration = 120
-internal val OutTransitionDuration = 75
+internal const val InTransitionDuration = 120
+internal const val OutTransitionDuration = 75
private val DropdownMenuOpenCloseTransition = transitionDefinition {
state(false) {
@@ -263,7 +264,7 @@
menuBounds: PxBounds,
density: Density
): TransformOrigin {
- val inset = with(density) { MenuElevation.toPx() }
+ val inset = with(density) { MenuElevationInset.toPx() }
val realMenuBounds = PxBounds(
menuBounds.left + inset,
menuBounds.top + inset,
@@ -313,7 +314,7 @@
popupSize: IntSize
): IntOffset {
// The padding inset that accommodates elevation, needs to be taken into account.
- val inset = with(density) { MenuElevation.toIntPx() }
+ val inset = with(density) { MenuElevationInset.toIntPx() }
val realPopupWidth = popupSize.width - inset * 2
val realPopupHeight = popupSize.height - inset * 2
val contentOffsetX = with(density) { contentOffset.x.toIntPx() }