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

Adaptive Cards | New line breaks and code blocks are not being rendered properly #1087

Open
karantrehan3 opened this issue Dec 24, 2023 · 5 comments
Assignees
Labels
bug Something isn't working platform-issue Teams JS issue

Comments

@karantrehan3
Copy link

Metadata:

  • Platform: Web
  • Using Nodejs
  • Packages being used: botbuilder

Problem:

When trying to sent an adaptive card attachment as the response activity via context.sendActivity (using the same reference as here), The line breaks are not rendered well and neither the code block is rendered. I am assuming that the latter is not supported explicitly but:

  1. Why the line-breaks \n are not being supported?
  2. If I send a text as the response activity then that renders the code block but then why does the adaptive card not render it? Is it difficult to provide the support for code blocks via markdown in adaptive cards?

Sample Payload:

{
  "type": "message",
  "attachmentLayout": "list",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "content": {
        "type": "AdaptiveCard",
        "$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.3",
        "msteams": {
          "width": "full"
        },
        "body": [
          {
            "type": "TextBlock",
            "text": "**From online search:**",
            "horizontalAlignment": "left",
            "isSubtle": false,
            "wrap": true,
            "style": "default",
            "separator": false,
            "isVisible": true
          },
          {
            "type": "TextBlock",
            "text": "Certainly! Below is a simple Python function that checks if a given array (or list) is sorted in non-decreasing order (i.e., each element is less than or equal to the next). If you want to check for strictly increasing order, you would just need to change the comparison from `<=` to `<`.\n\n\n\n```python\n\ndef is_sorted(array):\n\n    return all(array[i] <= array[i+1] for i in range(len(array) - 1))\n\n\n\n# Example usage:\n\nmy_array = [1, 2, 2, 3, 4, 5]\n\nprint(is_sorted(my_array))  # Output: True\n\n\n\nmy_array = [1, 2, 3, 4, 3, 5]\n\nprint(is_sorted(my_array))  # Output: False\n\n```\n\n\n\nThis function uses the `all()` function to check if all adjacent pairs of elements in the array satisfy the condition `array[i] <= array[i+1]`. If this is true for all pairs, then the array is sorted.\n\n\n\nIf you want to check if the array is sorted in non-increasing order, you can modify the comparison accordingly:\n\n\n\n```python\n\ndef is_sorted_descending(array):\n\n    return all(array[i] >= array[i+1] for i in range(len(array) - 1))\n\n\n\n# Example usage:\n\nmy_array = [5, 4, 4, 3, 2, 1]\n\nprint(is_sorted_descending(my_array))  # Output: True\n\n\n\nmy_array = [5, 4, 3, 2, 3, 1]\n\nprint(is_sorted_descending(my_array))  # Output: False\n\n```\n\n\n\nRemember that these functions assume the array is sorted in non-decreasing or non-increasing order, which allows for consecutive duplicate elements. If you need to check for strictly increasing or decreasing order, adjust the comparison operators accordingly.",
            "horizontalAlignment": "left",
            "isSubtle": false,
            "wrap": true,
            "style": "default",
            "separator": false,
            "isVisible": true
          }
        ],
        "rtl": false
      }
    }
  ],
  "inputHint": "acceptingInput"
}

Output Screenshot: (supports neither new line \n and neither the code blocks)

image

Now if this text is sent directly as the response activity

"Certainly! Below is a simple Python function that checks if a given array (or list) is sorted in non-decreasing order (i.e., each element is less than or equal to the next). If you want to check for strictly increasing order, you would just need to change the comparison from <= to <.\n\npython\ndef is_sorted(array):\n return all(array[i] <= array[i+1] for i in range(len(array) - 1))\n\n# Example usage:\nmy_array = [1, 2, 2, 3, 4, 5]\nprint(is_sorted(my_array)) # Output: True\n\nmy_array = [1, 2, 3, 4, 3, 5]\nprint(is_sorted(my_array)) # Output: False\n\n\nThis function uses the all() function to check if all adjacent pairs of elements in the array satisfy the condition array[i] <= array[i+1]. If this is true for all pairs, then the array is sorted.\n\nIf you want to check if the array is sorted in non-increasing order, you can modify the comparison accordingly:\n\npython\ndef is_sorted_descending(array):\n return all(array[i] >= array[i+1] for i in range(len(array) - 1))\n\n# Example usage:\nmy_array = [5, 4, 4, 3, 2, 1]\nprint(is_sorted_descending(my_array)) # Output: True\n\nmy_array = [5, 4, 3, 2, 3, 1]\nprint(is_sorted_descending(my_array)) # Output: False\n\n\nRemember that these functions assume the array is sorted in non-decreasing or non-increasing order, which allows for consecutive duplicate elements. If you need to check for strictly increasing or decreasing order, adjust the comparison operators accordingly."

Output Screenshot

image

The only difference between the two textual payloads is that in the case of adaptive cards, I attempted adding a new line character based on the guideline here Using \n\n in place of \n.

@Prasad-MSFT
Copy link

We are able to repro this issue. We have raised a bug for the same. We will inform you once we get any further update from engineering team. Thanks!

@ChetanSharma-msft ChetanSharma-msft added bug Something isn't working platform-issue Teams JS issue and removed needs-triage 🔍 labels Dec 27, 2023
@karantrehan3
Copy link
Author

We are able to repro this issue. We have raised a bug for the same. We will inform you once we get any further update from engineering team. Thanks!

Thanks @Prasad-MSFT. Is there any ETA associated to this (a ball-park number)? This is affecting our app's UX, would like this to be addressed on priority.

@Prasad-MSFT
Copy link

@karantrehan3 - Apologies. Currently there is no ETA to share. We are following up with engineering team about this issue. We will update this thread once we hear from them. Thanks!

@karantrehan3
Copy link
Author

@Prasad-MSFT Following up here, do we have any update + an ETA?

@Prasad-MSFT
Copy link

@karantrehan3 - At the moment, we have not received any updates from the engineering team. However, we have made them aware of the seriousness of the issue. As soon as we receive any updates from them, we will notify you in this thread.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform-issue Teams JS issue
Projects
None yet
Development

No branches or pull requests

3 participants