client.views.update does not update modal on user interaction
See original GitHub issueDescription
I’m trying to update a modal view after a user has selected an item from an interactive static select. In the action handler for that element, I am filtering down a list of items in a second static select (not interactive), and then I rebuild the view and call client.views.update
with the new view. I’m setting view_id
, hash
, and the view
property, per this example.
I get an ok
response from the call, but the modal does not update - the same set of options are available in the second static select, and not the filtered down list.
When looking for help on this, most of the issues boil down to people trying to update the modal on view submission (and using ack()
with response_action
in the view submission handler being the recommendation) but I’m just dealing with user interaction in the modal itself, not yet submitted.
What type of issue is this? (place an x
in one of the [ ]
)
- [ x ] bug
- enhancement (feature request)
- [ x ] question
- documentation related
- testing related
- discussion
Requirements (place an x
in each of the [ ]
)
- [ x ] I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
- [ x ] I’ve read and agree to the Code of Conduct.
- [ x ] I’ve searched for any related issues and avoided creating a duplicate issue.
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: 2.3.0
node version: 12.16.1
OS version(s): macOS Catalina 10.15.7
Steps to reproduce:
- Open a modal with a given view
- Handle the action for a user selection in the first static_select, filter a list of options, and push a new view
Example of the code being called to update the view:
const updatedViewResult = await client.views.update({
view_id: body.view.id,
hash: body.view.hash,
view: modals.draft_new_message_INTERACTIVE(
users,
modals.draft_dropdown_builder(filteredChannels)
),
});
console.log(updatedViewResult);
Example of the response from the view showing ok
:
ok: true,
view: {
id: 'V01CJV2GD4G',
team_id: 'T019SLF5478',
type: 'modal',
blocks: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
private_metadata: '',
callback_id: 'draft_new_message',
state: { values: {} },
hash: '1601646187.nrai5pOi',
title: { type: 'plain_text', text: 'On Behalf Of', emoji: true },
clear_on_close: false,
notify_on_close: false,
close: { type: 'plain_text', text: 'Cancel', emoji: true },
submit: { type: 'plain_text', text: 'Submit', emoji: true },
previous_view_id: null,
root_view_id: 'V01CJV2GD4G',
app_id: 'A01A5J7D6UC',
external_id: '',
app_installed_team_id: 'T019SLF5478',
bot_id: 'B019WB7RLH3'
},
response_metadata: {
scopes: [
'chat:write',
'im:history',
'groups:history',
'channels:history',
'mpim:history',
'commands',
'chat:write.public',
'users:read',
'reminders:read',
'reminders:write',
'im:write'
]
}
}```
#### Expected result:
I expected the view to update so the 2nd list of options was filtered. In this example, I'm selecting a user, and trying to filter down a list of channels based on whether the selected user is a member of those channels. There are two configured channels, but the user is only a member of `general`. In before/after screenshots, you can see that the list of channels is unchanged.
#### Actual result:
Original view remains, and is not updated.
#### Attachments:


Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Hey @k-mckinney,
I had some time to recreate your example following your steps:
I had the same result as you, where the second menu contained the original (unfiltered) values.
I suspect this is because we’re using a static select menu. According to the defining view objects
views.update
should contain the same input blocks and elements. I imagine this is necessary for Slack to reliably preserve the state of the first select menu.Is it possible for you use a select menu with an external data source?
Hi @k-mckinney, did you get the working solution? I am trying same but modal doesn’t maintain selection on views.update. Required help here.