-
-
Notifications
You must be signed in to change notification settings - Fork 916
Porting BottomSheet accessibility from v2 to v4 #1288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f6f52aa
4144828
cf21b04
d076e97
23d3bcd
01d49e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,10 @@ import { | |
| DEFAULT_DISAPPEARS_ON_INDEX, | ||
| DEFAULT_ENABLE_TOUCH_THROUGH, | ||
| DEFAULT_PRESS_BEHAVIOR, | ||
| DEFAULT_ACCESSIBLE, | ||
| DEFAULT_ACCESSIBILITY_ROLE, | ||
| DEFAULT_ACCESSIBILITY_LABEL, | ||
| DEFAULT_ACCESSIBILITY_HINT, | ||
| } from './constants'; | ||
| import { styles } from './styles'; | ||
| import type { BottomSheetDefaultBackdropProps } from './types'; | ||
|
|
@@ -33,6 +37,10 @@ const BottomSheetBackdropComponent = ({ | |
| onPress, | ||
| style, | ||
| children, | ||
| accessible: _providedAccessible = DEFAULT_ACCESSIBLE, | ||
| accessibilityRole: _providedAccessibilityRole = DEFAULT_ACCESSIBILITY_ROLE, | ||
| accessibilityLabel: _providedAccessibilityLabel = DEFAULT_ACCESSIBILITY_LABEL, | ||
| accessibilityHint: _providedAccessibilityHint = DEFAULT_ACCESSIBILITY_HINT, | ||
| }: BottomSheetDefaultBackdropProps) => { | ||
| //#region hooks | ||
| const { snapToIndex, close } = useBottomSheet(); | ||
|
|
@@ -112,27 +120,35 @@ const BottomSheetBackdropComponent = ({ | |
| }, | ||
| [disappearsOnIndex] | ||
| ); | ||
| //#endregion | ||
|
|
||
| return pressBehavior !== 'none' ? ( | ||
| <TapGestureHandler onGestureEvent={gestureHandler}> | ||
| const AnimatedView = () => { | ||
| return ( | ||
| <Animated.View | ||
| style={containerStyle} | ||
| pointerEvents={pointerEvents} | ||
| accessible={true} | ||
| accessibilityRole="button" | ||
| accessibilityLabel="Bottom Sheet backdrop" | ||
| accessibilityHint={`Tap to ${ | ||
| typeof pressBehavior === 'string' ? pressBehavior : 'move' | ||
| } the Bottom Sheet`} | ||
| accessible={_providedAccessible ?? undefined} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would you mark the root There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, just tested this and this is the problem I'm seeing as well. @flo-sch I see you just opened an accessibility PR, did you want to take a look at this as well there? |
||
| accessibilityRole={_providedAccessibilityRole ?? undefined} | ||
| accessibilityLabel={_providedAccessibilityLabel ?? undefined} | ||
| accessibilityHint={ | ||
| _providedAccessibilityHint | ||
| ? _providedAccessibilityHint | ||
| : `Tap to ${ | ||
| typeof pressBehavior === 'string' ? pressBehavior : 'move' | ||
| } the Bottom Sheet` | ||
| } | ||
| > | ||
| {children} | ||
| </Animated.View> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you also need to add the accessibility props to the Maybe add this to a local const and use that because it is the exact same component as is used inside
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, done. |
||
| ); | ||
| }; | ||
| //#endregion | ||
|
|
||
| return pressBehavior !== 'none' ? ( | ||
| <TapGestureHandler onGestureEvent={gestureHandler}> | ||
| <AnimatedView /> | ||
| </TapGestureHandler> | ||
| ) : ( | ||
| <Animated.View pointerEvents={pointerEvents} style={containerStyle}> | ||
| {children} | ||
| </Animated.View> | ||
| <AnimatedView /> | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| const DEFAULT_ACCESSIBLE = true; | ||
| const DEFAULT_ACCESSIBILITY_ROLE = 'adjustable'; | ||
| const DEFAULT_ACCESSIBILITY_LABEL = 'Bottom sheet handle'; | ||
| const DEFAULT_ACCESSIBILITY_HINT = | ||
| 'Drag up or down to extend or minimize the bottom sheet'; | ||
|
|
||
| export { | ||
| DEFAULT_ACCESSIBLE, | ||
| DEFAULT_ACCESSIBILITY_ROLE, | ||
| DEFAULT_ACCESSIBILITY_LABEL, | ||
| DEFAULT_ACCESSIBILITY_HINT, | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.