slackapi / bolt-python

A framework to build Slack apps using Python
https://slack.dev/bolt-python/
MIT License
1.02k stars 236 forks source link

Allow for the "confirm" field within the Overflow menu element to be used on a per-item basis #1080

Closed Keanro closed 1 month ago

Keanro commented 1 month ago

When using the Overflow menu element, you can create a confirmation pop-up for the items within it. Unfortunately, the "confirm" object sits on the top layer of the Overflow menu element, meaning the confirmation will appear regardless of what you select. Ideally, the "confirm" object could be placed within the individual items so that the message is unique per selection (if you even want a confirmation for your items).

In my use case, I am updating an app Home Page with scheduled messages a user has. On clicking the Overflow menu for each item, the user can either cancel or reschedule the message. My hope was to only create a confirmation pop-up when a user selected the cancellation option, whereas reschedule would continue a different path.

Current flow

https://github.com/slackapi/bolt-python/assets/76880818/9ecdbc73-7868-418a-acc8-5867b5838a90

Block Kit that currently works

{
  "type": "home",
  "blocks": [
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "Check out this message!"
      },
      "accessory": {
        "type": "overflow",
        "action_id": "button_overflow_cancel_reschedule",
        "options": [
          {
            "text": {
              "type": "plain_text",
              "text": "Reschedule message",
              "emoji": true
            },
            "value": "button_reschedule"
          },
          {
            "text": {
              "type": "plain_text",
              "text": "Cancel message",
              "emoji": true
            },
            "value": "button_cancel"
          }
        ],
        "confirm": {
          "title": {
            "type": "plain_text",
            "text": "Are you sure?"
          },
          "text": {
            "type": "plain_text",
            "text": "After cancelling a message, you need to manually recreate it."
          },
          "confirm": {
            "type": "plain_text",
            "text": "Destroy the message!"
          },
          "deny": {
            "type": "plain_text",
            "text": "Stop, I've changed my mind!"
          }
        }
      }
    }
  ]
}

Ideal Block Kit format (does not work // invalid additional property: confirm)

{
  "type": "home",
  "blocks": [
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "Check out this message!"
      },
      "accessory": {
        "type": "overflow",
        "action_id": "button_overflow_cancel_reschedule",
        "options": [
          {
            "text": {
              "type": "plain_text",
              "text": "Reschedule message",
              "emoji": true
            },
            "value": "button_reschedule"
          },
          {
            "text": {
              "type": "plain_text",
              "text": "Cancel message",
              "emoji": true
            },
            "value": "button_cancel",
            "confirm": {
              "title": {
                "type": "plain_text",
                "text": "Are you sure?"
              },
              "text": {
                "type": "plain_text",
                "text": "After cancelling a message, you need to manually recreate it."
              },
              "confirm": {
                "type": "plain_text",
                "text": "Destroy the message!"
              },
              "deny": {
                "type": "plain_text",
                "text": "Stop, I've changed my mind!"
              }
            }
          }
        ]
      }
    }
  ]
}

Category (place an x in each of the [ ])

Requirements

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

seratch commented 1 month ago

Hi @Keanro, thank you for reaching out.

Regrettably, we do not foresee such major structural changes to the Block Kit on our platform.

However, for your specific use case, I recommend utilizing a modal dialog as a more flexible way to show confirmation dialog than the overflow's built-in confirm dialog. This would mean you could have @app.action("button_overflow_cancel_reschedule") listener which could open a modal depending on the selected value within the action payload. The views.open API can be used to launch a pop-up modal, where you're able to leverage most components from Block Kit. You might want to try https://app.slack.com/block-kit-builder for experimenting with UI concepts for the modal.

I hope this was helpful to you!

Keanro commented 1 month ago

Thanks for responding so quickly, @seratch! I'll go ahead with your suggestion and use views.open. As there's nothing else needed from me, I'll go ahead and close this issue.