slackapi/bolt-js

External select not refreshing

jacklein opened this issue ยท 4 comments

(Filling out the following with as much detail as you can provide will help us solve your issue sooner.)

Reproducible in:

The Slack SDK version

^3.17.1

Node.js runtime version

v20.11.0

Hi! I have an external select inside a modal with placeholder text of "Search for a place...". When a user selects a place, and presses the "Add place" button, I add the selection to a list by updating the modal. However, when I update the modal, the external select doesn't revert back to the placeholder text, I think because the state object gets passed to the updated modal. How can I refresh the state so that every time I update the modal I see the placeholder text?

Screen.Recording.2024-02-13.at.9.56.59.AM.mov

Hi, @jacklein! Thanks so much for submitting this question and for the video demonstrating your issue! ๐Ÿ™Œ

After doing some research on the select menu with external data types, it seems like the placeholder is only intended to surface when an option is not selected. In this case, an option is considered "selected" once you select it from the menu and from that point onwards you have no choice but to select another option to change the value in the field.

Something you could try is calling a views.update for your modal after hitting the "Add place" button that completely updates / replaces the form so it's fresh and new, but demonstrates all of your selected options below it like you've shown in the video.

I hope this helps! โœจ

@hello-ashleyintech Thank you for the response! Sorry if I wasn't exactly clear up top, but I am calling views.update with a fresh external select block. However, the state object which has a selected_value from when I do the first select doesn't get reset and gets passed to the new modal. Because of this, the new external select block shows the previously selected value. I tried to pass a fresh state into the views.update like:

views.update({
   ...
   state: {},
   ...
})

but it doesn't seem like I can do this.

So ultimately I'm trying to reset the state variable when I call views.update.

Ah, I see! Thanks for the clarification @jacklein! ๐Ÿ™Œ

This may not be exactly what you want since it's not directly updating that state, but take a look at this suggestion and let me know if it would work in your use case!

@hello-ashleyintech ahhh ok thanks I will try this workaround ๐Ÿ™