question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

client.views.update does not update modal on user interaction

See original GitHub issue

Description

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:

  1. Open a modal with a given view
  2. 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:

![image](https://user-images.githubusercontent.com/14983713/94929880-48022f00-048b-11eb-836e-221ecd3f7ba7.png)
![image](https://user-images.githubusercontent.com/14983713/94929903-4e90a680-048b-11eb-9c58-8a9348904a82.png)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mwbrookscommented, Oct 9, 2020

Hey @k-mckinney,

I had some time to recreate your example following your steps:

  1. Open a modal with 2 select static menus
  2. Select an option from the first select menu
  3. Receive the action with Bolt
  4. Update the view to be identical, except the second menu’s values are now filtered

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. image

Is it possible for you use a select menu with an external data source?

0reactions
brijeshpant83commented, Apr 9, 2022

Description

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:

  1. Open a modal with a given view
  2. 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:

![image](https://user-images.githubusercontent.com/14983713/94929880-48022f00-048b-11eb-836e-221ecd3f7ba7.png)
![image](https://user-images.githubusercontent.com/14983713/94929903-4e90a680-048b-11eb-9c58-8a9348904a82.png)

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

views.update method - Slack API
Update a view by passing a new view definition object along with the view_id returned in views. open or the external_id . See...
Read more >
Slack client.views.update not maintaining selected input values
I want to select dropdown one and based on selection looking to populate dropdown two and on update all selected values should be...
Read more >
Modals | Slack SDK for Java
Modals. Modals are a focused surface to collect data from users or display dynamic and interactive information. To users, modals appear as focused...
Read more >
How to handle long running request(s) after sending response?
And I am also not doing anything fancy like updating a modal/view later on with the hook. The long running task does not...
Read more >
Workbot actions for Slack - Workato Docs
Post command reply; Post message; Open/update or push modal view; Publish app home ... The Workbot recipe job can suspend until the user...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found