mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Fix for Modal behavior when menu button pressed on Apple TV (Issue #15313)
Summary: **Motivation** On Apple TV, pressing the menu button destroys the native view that backs the `Modal` component, causing an app using this component to get into a broken state. This fix implements `onRequestClose` for tvOS to have the same behavior as it does for the Android back button. **Test plan** Manually tested this with the `ModalExample` in the `RNTester` app. See also the test code in issue #15313. Closes https://github.com/facebook/react-native/pull/15341 Differential Revision: D5651035 Pulled By: shergin fbshipit-source-id: 54bf66887bbe85940567e63e90b437ac4a8daf9a
This commit is contained in:
committed by
Facebook Github Bot
parent
14e67a379b
commit
0d3039f1a0
@@ -118,10 +118,9 @@ class Modal extends React.Component {
|
||||
*/
|
||||
visible: PropTypes.bool,
|
||||
/**
|
||||
* The `onRequestClose` callback is called when the user taps the hardware back button.
|
||||
* @platform android
|
||||
* The `onRequestClose` callback is called when the user taps the hardware back button on Android or the menu button on Apple TV.
|
||||
*/
|
||||
onRequestClose: Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func,
|
||||
onRequestClose: (Platform.isTVOS || Platform.OS === 'android') ? PropTypes.func.isRequired : PropTypes.func,
|
||||
/**
|
||||
* The `onShow` prop allows passing a function that will be called once the modal has been shown.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user