Skip to content

Commit 0136a8e

Browse files
authored
fix: [IOPLT-995] Fix Talkback issue on Android when accordion is collapsed (#418)
## Short description This PR fixes a _Talkback_ issue on Android when the accordion is collapsed. Specifically, _Talkback_ was intercepting all interactive elements present in the `body` prop, even when the accordion was collapsed. ## List of changes proposed in this pull request - Add a dynamic value to `importantForAccessibility` prop based on `expanded` value ## How to test 1. Activate Talkback on Android 2. Launch the example app 3. Go to the **Collapsible** page 4. Navigate through the content. When you reach "Come posso eliminare un metodo di pagamento" (collapsed), the screen reader should read the next question
1 parent 0a23ac0 commit 0136a8e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

example/src/pages/Collapsible.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ const assistanceData: Array<AccordionItem> = [
3131
<Body>
3232
I tuoi metodi di pagamento sono visualizzati come card nella parte alta
3333
dello schermo del Portafoglio. Seleziona la card del metodo che vuoi
34-
eliminare e poi premi Elimina questo metodo!
34+
eliminare e poi premi{" "}
35+
<Body onPress={() => null} asLink>
36+
Elimina questo metodo!
37+
</Body>
3538
</Body>
3639
)
3740
},

src/components/accordion/AccordionItem.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ export const AccordionItem = ({
9999
</View>
100100
</TouchableWithoutFeedback>
101101

102-
<Animated.View style={bodyAnimatedStyle}>
102+
<Animated.View
103+
style={bodyAnimatedStyle}
104+
importantForAccessibility={expanded ? "auto" : "no-hide-descendants"}
105+
>
103106
<View style={bodyInnerStyle} onLayout={onBodyLayout}>
104107
{typeof body === "string" ? <Body>{body}</Body> : body}
105108
</View>
@@ -108,6 +111,7 @@ export const AccordionItem = ({
108111
{/* This gradient adds a smooth end to the content. If it is missing,
109112
the content will be cut sharply during the height transition. */}
110113
<LinearGradient
114+
accessible={false}
111115
style={{
112116
height: accordionBodySpacing,
113117
position: "absolute",

0 commit comments

Comments
 (0)