diff --git a/app/src/main/java/com/orange/ods/app/ui/components/menus/MenuDropdown.kt b/app/src/main/java/com/orange/ods/app/ui/components/menus/MenuDropdown.kt index d039e322e..e902fcee3 100644 --- a/app/src/main/java/com/orange/ods/app/ui/components/menus/MenuDropdown.kt +++ b/app/src/main/java/com/orange/ods/app/ui/components/menus/MenuDropdown.kt @@ -101,6 +101,7 @@ fun MenuDropdown() { text = recipe.title, icon = if (hasIcons && recipe.iconResId != null) painterResource(id = recipe.iconResId) else null, divider = hasDividerExample && index == dividerIndex, + enabled = index != MenuDropdownCustomizationState.MenuItemCount - 2, onClick = { clickOnElement(context, recipe.title) } ) } diff --git a/changelog.md b/changelog.md index 07d4a5fc1..7d0e85caa 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - \[Lib\] Update `OdsHorizontalCard`, `OdsSmallCard`, `OdsVerticalHeaderFirstCard` and `OdsVerticalImageFirstCard` APIs ([#597](https://github.com/Orange-OpenSource/ods-android/issues/597)) +### Fixed + +- \[Lib\] Fix a bug where `OdsDropdownMenu` was not dismissed on user click ([#617](https://github.com/Orange-OpenSource/ods-android/issues/617)) +- \[Lib\] Fix disabled color of text and icon in `OdsDropdownMenu` ([#617](https://github.com/Orange-OpenSource/ods-android/issues/617)) + ## [0.15.0](https://github.com/Orange-OpenSource/ods-android/compare/0.14.0...0.15.0) - 2023-09-12 ### Added diff --git a/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt b/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt index bc3153347..bc8017671 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt @@ -33,6 +33,7 @@ import com.orange.ods.compose.component.icon.OdsIcon import com.orange.ods.compose.component.utilities.Preview import com.orange.ods.compose.component.utilities.UiModePreviews import com.orange.ods.compose.theme.OdsTheme +import com.orange.ods.compose.utilities.extension.enable /** * ODS menus. @@ -63,7 +64,7 @@ fun OdsDropdownMenu( modifier = modifier.background(OdsTheme.colors.surface), offset = offset, properties = properties, - content = { items.forEach { it.Content() } } + content = { items.forEach { it.Content(onDismissRequest) } } ) } @@ -152,18 +153,33 @@ class OdsDropdownMenuItem private constructor( onClick: () -> Unit ) : this(text, icon as Any?, enabled, divider, onClick) + private var onDismissRequest: () -> Unit = {} + + @Composable + internal fun Content(onDismissRequest: () -> Unit) { + this.onDismissRequest = onDismissRequest + Content() + } + @Composable override fun Content(modifier: Modifier) { - DropdownMenuItem(onClick = onClick, enabled = enabled) { + DropdownMenuItem( + onClick = { + onClick() + onDismissRequest() + }, + enabled = enabled + ) { icon?.let { OdsIcon( graphicsObject = icon, contentDescription = "", tint = OdsTheme.colors.onSurface, + enabled = enabled, modifier = Modifier.padding(end = dimensionResource(id = R.dimen.spacing_m)), ) } - Text(text = text, style = OdsTheme.typography.body1, color = OdsTheme.colors.onSurface) + Text(text = text, style = OdsTheme.typography.body1, color = OdsTheme.colors.onSurface.enable(enabled = enabled)) } if (divider) OdsDivider() }