Skip to content
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

Use of submit_disabled in modal dialog #1033

Closed
davidlundeen-vexcel opened this issue Jun 11, 2021 · 3 comments
Closed

Use of submit_disabled in modal dialog #1033

davidlundeen-vexcel opened this issue Jun 11, 2021 · 3 comments
Labels
needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info question M-T: User needs support to use the project

Comments

@davidlundeen-vexcel
Copy link

Goal is to disable the Submit button until it's explicitly enabled. I'm having some timing issues where it looks like the view_submission event is being processed before a previous block_action processing completes

Reproducible in:

The Slack SDK version

slack-bolt==1.3.0
slack-sdk==3.3.0
slackclient==2.9.3
slackeventsapi==2.2.1

Python runtime version

Python 3.6.5

OS info

Microsoft Windows [Version 10.0.19041.1052]

Steps to reproduce:

Running the attached code results in a dialog with a submit button.

### Expected result:

A dialog displayed with the submit button disabled.

Actual result:

A dialog displayed with the submit button enabled.

Requirements

For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@mwbrooks mwbrooks added question M-T: User needs support to use the project and removed untriaged labels Jun 11, 2021
@mwbrooks
Copy link
Member

Hey @davidlundeen-vexcel 👋🏻 Thanks for reaching out!

Would you mind linking to a code sample for us to review? I see you mentioned uploading it, but it wasn't attached. Since this example is a little more complex, I don't think it'll be effective for us to recreate it manually.

It would also be helpful to know if you're using Socket Mode or a Request URL.

Cheers!
Michael

@mwbrooks mwbrooks added the needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info label Jun 11, 2021
@davidlundeen-vexcel
Copy link
Author

Hi @mwbrooks, thanks for the response. I'm pasting code (minus identifiers) since I didn't upload corerctly last time. I'm using Request URL mode.

Thanks for the help!

import json, os, uuid, datetime

from flask import Flask, request, Response, make_response
from slack import WebClient

SLACK_BOT_TOKEN="AAA"
SLACK_SIGNING_SECRET="BBB"
VERIFICATION_TOKEN="CCC"

BLOCK_PROJECT_TYPE_SELECTOR = {
                  "type": "input",
                  "dispatch_action":True,
                  "block_id":"BLOCK_PROJECT_TYPE_SELECTOR",
                  "element": {
                      "type": "plain_text_input",
                      "placeholder": {
                          "type": "plain_text",
                          "text": "Submit Test"
                      },
                      "action_id": "project_type_selection_action",
                  },
                  "label": {
                  "type": "plain_text",
                  "text": "Enter Text"
                  },
            }

view_id = None

app = Flask(__name__, template_folder='')

client = WebClient(token=SLACK_BOT_TOKEN)


def get_view ():
    view = {
      "type": "modal",
#      "submit_disabled":True,
      "title": 
      {
        "type": "plain_text",
        "text": "Test"
      },
      "submit": 
      {
        "type": "plain_text",
        "text": "Submit"
      },
      "callback_id": "home_view", 
      "blocks": [BLOCK_PROJECT_TYPE_SELECTOR]
    }

    return view


@app.route('/slack/events/interactive', methods=['GET', 'POST'])
def interactivity_event_hook():
    global view_id
    payload = json.loads(request.form ["payload"])
    if payload ["type"] == "shortcut":
        return load_initial_modal(payload)

    view=get_view ()
    try:
      client.views_update(
        trigger_id=payload["trigger_id"],
        view_id = view_id,
        hash=payload ["view"] ["hash"],
        view=view
      )
      return make_response("", 200)
    except Exception as e:
      print(f"Error publishing home tab: {e}")
      return {"status": 500}


def load_initial_modal (payload,):
    global view_id
    view = get_view ()
    try:
        resp = client.views_open (trigger_id=payload["trigger_id"],submit_disabled=True,view=view)
        view_id = resp ["view"] ["id"]
    except Exception as e:
      print(f"Error publishing home tab: {e}")
    return {"status": 200}
       

if __name__ == '__main__':
    app.run(port=3000)

@seratch
Copy link
Member

seratch commented Jul 22, 2021

Hi @davidlundeen-vexcel, sorry for our slow response here.

The API document may not be clear enough but as of today, this option is available only for "workflow_step" type modals. Thus, your app cannot use the option for normal modals. See also: slackapi/node-slack-sdk#1276 (comment)

Let us close this issue now but please feel free to write in if you have any follow up questions.

@seratch seratch closed this as completed Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

3 participants