Fix keyboard support on the dropdown (#1073)

* Fix: dropdown now supports accessibility labels and keyboard controls

* Fix event propagation around the post dropdown
This commit is contained in:
Paul Frazee 2023-07-28 18:12:21 -05:00 committed by GitHub
parent 45da8a86c9
commit 1195f28992
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 109 additions and 39 deletions

View file

@ -0,0 +1,22 @@
import React from 'react'
import {View} from 'react-native'
/**
* This utility function captures events and stops
* them from propagating upwards.
*/
export function EventStopper({children}: React.PropsWithChildren<{}>) {
const stop = (e: any) => {
e.stopPropagation()
}
return (
<View
onStartShouldSetResponder={_ => true}
onTouchEnd={stop}
// @ts-ignore web only -prf
onClick={stop}
onKeyDown={stop}>
{children}
</View>
)
}