-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ack() on view submission does not accept response_action arguments #305
Comments
Has this been fixed? How am I supposed to send an error message to a modal upon submission using bolt? |
@jacklein Unfortunately, it hasn't been fixed yet. ... I know this is not a preferable workaround but the only thing TypeScript users can do as a workaround is cast the response to app.view('callback_id', ({ ack }) => {
ack({
response_action: 'errors',
errors: []
} as any /* Tentative workaround for https://github.com/slackapi/bolt/issues/305 */);
}); I will take look at this issue. I'm also a big fan of TS. |
@seratch I'm using node.js not typescript (I'm not at all familiar with typescript), is there any workaround for plain javascript? |
@jacklein In JavaScript, there is no obstacle. You can give const errors = {};
if (title.length <= 5) {
errors['input-title'] = 'Title must be longer than 5 characters'
}
if (Object.entries(errors).length > 0) {
ack({
response_action: 'errors',
errors: errors
});
} else {
ack(); // close this modal - or also possible to set `response_action: 'clear'`
} |
@seratch You really saved my life with that example code. Thank you, I really appreciate the help. One potential bug I would like to point out is I had a group of date pickers that looks like:
and the error message wasn't working for |
An {
"type": "input",
"block_id": "departure_date",
"element": {
"type": "datepicker",
"action_id": "input",
"placeholder": {
"type": "plain_text",
"text": "Departure date"
},
},
"label": {
"type": "plain_text",
"text": "Departure date",
"emoji": true
}
},
{
"type": "input",
"block_id": "return_date",
"element": {
"type": "datepicker",
"action_id": "input",
"placeholder": {
"type": "plain_text",
"text": "Return date"
},
},
"label": {
"type": "plain_text",
"text": "Return date",
"emoji": true
}
} |
@seratch Awesome! Thanks again, really appreciate your help! |
Description
The
ack()
function should accept any value that is acceptable to respond to an incoming HTTP request. In the context of view submissions, there are a fewresponse_action
s that are acceptable, but currently do not work because theack
utility is incorrectly typed to takeRespondArguments
.The solution is likely to use the
AckFn<T>
type to describe the additionalresponse_action
payloads:update
push
clear
errors
https://api.slack.com/surfaces/modals/using#modifying
https://api.slack.com/surfaces/modals/using#displaying_errors
Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: 1.4.1
node version: all
OS version(s): all
Steps to reproduce:
ack({ response_action: "clear" })
in the listener.Expected result:
The TypeScript typechecker is happy.
Actual result:
The TypeScript typechecker is sad.
The text was updated successfully, but these errors were encountered: