From 0236877849fbddf7966a0c7eaaf7c465df535720 Mon Sep 17 00:00:00 2001 From: cttsai-stripe Date: Wed, 8 Jan 2025 13:44:04 -0800 Subject: [PATCH] Modify SavedPaymentMethodTab click group to match the accessibility requirements (#9874) --- .../paymentsheet/ui/SavedPaymentMethodTab.kt | 24 ++++++++----------- .../paymentsheet/ui/PaymentOptionTest.kt | 2 -- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/SavedPaymentMethodTab.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/SavedPaymentMethodTab.kt index 1310b95fff9..d3c2f9af2c0 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/SavedPaymentMethodTab.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/SavedPaymentMethodTab.kt @@ -59,13 +59,13 @@ internal val SavedPaymentMethodsTopContentPadding = 12.dp @Composable internal fun SavedPaymentMethodTab( + modifier: Modifier = Modifier, viewWidth: Dp, isSelected: Boolean, shouldShowModifyBadge: Boolean, isEnabled: Boolean, isClickable: Boolean = isEnabled, iconRes: Int, - modifier: Modifier = Modifier, iconTint: Color? = null, @DrawableRes labelIcon: Int? = null, labelText: String = "", @@ -84,14 +84,19 @@ internal fun SavedPaymentMethodTab( ) }, content = { - Column { + Column( + modifier = Modifier + .testTag("${SAVED_PAYMENT_METHOD_CARD_TEST_TAG}_$labelText") + .selectable( + selected = isSelected, + enabled = isClickable, + onClick = onItemSelectedListener, + ), + ) { SavedPaymentMethodCard( isSelected = isSelected, - isClickable = isClickable, - labelText = labelText, iconRes = iconRes, iconTint = iconTint, - onItemSelectedListener = onItemSelectedListener, ) LpmSelectorText( @@ -137,11 +142,8 @@ private fun SavedPaymentMethodBadge( @Composable private fun SavedPaymentMethodCard( isSelected: Boolean, - isClickable: Boolean, iconRes: Int, iconTint: Color?, - labelText: String, - onItemSelectedListener: (() -> Unit), modifier: Modifier = Modifier, ) { SectionCard( @@ -156,12 +158,6 @@ private fun SavedPaymentMethodCard( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .fillMaxSize() - .testTag("${SAVED_PAYMENT_METHOD_CARD_TEST_TAG}_$labelText") - .selectable( - selected = isSelected, - enabled = isClickable, - onClick = onItemSelectedListener, - ), ) { Image( painter = painterResource(iconRes), diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentOptionTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentOptionTest.kt index 62edd606c47..04de11dcb47 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentOptionTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentOptionTest.kt @@ -4,7 +4,6 @@ import android.os.Build import androidx.compose.ui.test.assertContentDescriptionEquals import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithText -import androidx.compose.ui.test.onParent import androidx.compose.ui.unit.dp import androidx.test.ext.junit.runners.AndroidJUnit4 import com.stripe.android.paymentsheet.R @@ -39,7 +38,6 @@ class PaymentOptionTest { composeTestRule .onNodeWithText(label) - .onParent() .assertContentDescriptionEquals("Card ending in 4 2 4 2 ") } }