From 30d0fdb399b16bf587e7326bd4724852ecd81f8a Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Wed, 8 Jul 2020 16:45:26 +0530 Subject: [PATCH 1/4] Fix Alert API docs --- docs/alert.md | 54 +++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/docs/alert.md b/docs/alert.md index 2c36eccd9db..f39592eb90f 100644 --- a/docs/alert.md +++ b/docs/alert.md @@ -40,8 +40,7 @@ const App = () => { style: "cancel" }, { text: "OK", onPress: () => console.log("OK Pressed") } - ], - { cancelable: false } + ] ); const createThreeButtonAlert = () => @@ -59,8 +58,7 @@ const App = () => { style: "cancel" }, { text: "OK", onPress: () => console.log("OK Pressed") } - ], - { cancelable: false } + ] ); return ( @@ -101,8 +99,7 @@ class App extends Component { style: "cancel" }, { text: "OK", onPress: () => console.log("OK Pressed") } - ], - { cancelable: false } + ] ); createThreeButtonAlert = () => @@ -120,8 +117,7 @@ class App extends Component { style: "cancel" }, { text: "OK", onPress: () => console.log("OK Pressed") } - ], - { cancelable: false } + ] ); render() { @@ -163,31 +159,33 @@ On Android at most three buttons can be specified. Android has a concept of a ne - Two buttons mean 'negative', 'positive' (such as 'Cancel', 'OK') - Three buttons mean 'neutral', 'negative', 'positive' (such as 'Later', 'Cancel', 'OK') -By default alerts on Android can be dismissed by tapping outside of the alert box. This event can be handled by providing an optional `options` parameter, with an `onDismiss` callback property `{ onDismiss: () => {} }`. +Alerts on Android can be dismissed by tapping outside of the alert box. It is disabled by default and can be enabled by providing an optional `options` parameter with the cancelable property set to true i.e. `{ cancelable: true }`. -Alternatively, the dismissing behavior can be disabled altogether by providing an optional options parameter with the cancelable property set to false i.e. `{ cancelable: false }`. +The dismissed event can be handled by providing an `onDismiss` callback property `{ onDismiss: () => {} }` inside the `options` parameter. Example usage: ```jsx -// Works on both Android and iOS -Alert.alert( - 'Alert Title', - 'My Alert Msg', - [ - { - text: 'Ask me later', - onPress: () => console.log('Ask me later pressed') - }, - { - text: 'Cancel', - onPress: () => console.log('Cancel Pressed'), - style: 'cancel' - }, - { text: 'OK', onPress: () => console.log('OK Pressed') } - ], - { cancelable: false } -); +// Works only on Android +Alert.alert('Alert Title', 'My Alert Msg', [ + { + text: 'Ask me later', + onPress: () => console.log('Ask me later pressed') + }, + { + text: 'Cancel', + onPress: () => console.log('Cancel Pressed'), + style: 'cancel' + }, + { text: 'OK', onPress: () => console.log('OK Pressed') }, + { + cancelable: true, + onDismiss: () => + console.log( + 'This alert was dismissed by tapping outside of the alert dialog.' + ) + } +]); ``` --- From 34da7e5f8552e9c93d33b19308b569523768c227 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Thu, 9 Jul 2020 12:00:50 +0530 Subject: [PATCH 2/4] Update docs/alert.md Co-authored-by: Ricky --- docs/alert.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/alert.md b/docs/alert.md index f39592eb90f..adaf91b246f 100644 --- a/docs/alert.md +++ b/docs/alert.md @@ -161,7 +161,7 @@ On Android at most three buttons can be specified. Android has a concept of a ne Alerts on Android can be dismissed by tapping outside of the alert box. It is disabled by default and can be enabled by providing an optional `options` parameter with the cancelable property set to true i.e. `{ cancelable: true }`. -The dismissed event can be handled by providing an `onDismiss` callback property `{ onDismiss: () => {} }` inside the `options` parameter. +The cancel event can be handled by providing an `onDismiss` callback property `{ onDismiss: () => {} }` inside the `options` parameter. Example usage: From ffb698e1269497fd98a1df02093f5fc8885a0c35 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Thu, 9 Jul 2020 12:00:58 +0530 Subject: [PATCH 3/4] Update docs/alert.md Co-authored-by: Ricky --- docs/alert.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/alert.md b/docs/alert.md index adaf91b246f..6d098ac16e2 100644 --- a/docs/alert.md +++ b/docs/alert.md @@ -166,7 +166,6 @@ The cancel event can be handled by providing an `onDismiss` callback property `{ Example usage: ```jsx -// Works only on Android Alert.alert('Alert Title', 'My Alert Msg', [ { text: 'Ask me later', From d2cacdb6879a1a56e1a1028273284ca787247bb3 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Thu, 9 Jul 2020 12:01:14 +0530 Subject: [PATCH 4/4] Update docs/alert.md Co-authored-by: Ricky --- docs/alert.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/alert.md b/docs/alert.md index 6d098ac16e2..9c4e51e2fa2 100644 --- a/docs/alert.md +++ b/docs/alert.md @@ -178,6 +178,7 @@ Alert.alert('Alert Title', 'My Alert Msg', [ }, { text: 'OK', onPress: () => console.log('OK Pressed') }, { + // cancelable and onDismiss only work on Android. cancelable: true, onDismiss: () => console.log(