From 097d9021ebc8008ff29cfbdaac35190b03350423 Mon Sep 17 00:00:00 2001 From: Sarah Jiang Date: Fri, 24 Sep 2021 14:32:27 -0700 Subject: [PATCH] Update views docs --- docs/_basic/listening_modals.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/_basic/listening_modals.md b/docs/_basic/listening_modals.md index c9525324b..357074058 100644 --- a/docs/_basic/listening_modals.md +++ b/docs/_basic/listening_modals.md @@ -6,11 +6,28 @@ order: 12 ---
-If a view payload contains any input blocks, you must listen to view_submission requests to receive their values. To listen to view_submission requests, you can use the built-in view() method. +If a view payload contains any input blocks, you must listen to `view_submission` requests to receive their values. To listen to `view_submission` requests, you can use the built-in `view()` method. -view() requires a callback_id of type string or RegExp. +`view()` requires a `callback_id` of type `string` or `RegExp`. -You can access the value of the input blocks by accessing the state object. state contains a values object that uses the block_id and unique action_id to store the input values. +You can access the value of the input blocks by accessing the `state` object. `state` contains a values object that uses the `block_id` and unique `action_id` to store the input values. + +--- + +##### Update views on submission + +To update a view in response to a `view_submission` event, you may pass a `response_action` of type `update` with a newly composed `view` to display in your acknowledgement. + +```javascript +// Update the view on submission +app.view('modal-callback-id', async ({ ack, body }) => { + await ack({ + response_action: 'update', + view: buildNewModalView(body), + }); +}); +``` +Similarly, there are options for [displaying errors](https://api.slack.com/surfaces/modals/using#displaying_errors) in response to view submissions. Read more about view submissions in our API documentation.