AdaptiveCards: [Adaptive Cards / Platform Discrepancy] Excess spacing in empty text blocks

Web / Desktop

What platform is your issue or question related to? (Delete other platforms).

  • Android
  • iOS
  • JavaScript
  • UWP

#4305 tracks this issue for .NET

Author or host

This is issue seen in the empty text playlod in Adaptive Card.

Version of SDK

1.2.5

Details

For empty text blocks – there is too much spacing rendered on Mobile as compared to Desktop (example in images below). Empty text block elements should not be rendered at all.

JSON for these cards attached

Desktop: image

Mobile: image

This issues in see in empty text block in Adaptive Card.

Payload :

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.0",
  "body": [
    {
      "type": "Container",
      "items": [
          {
          "type": "TextBlock",
          "text": "before"
        },
        {
          "type": "TextBlock",
          "text": ""
        },
        {
          "type": "TextBlock",
          "text": ""
        },
        {
          "type": "TextBlock",
          "text": "after"
        },
        {
          "type": "Image",
          "url": "http://adaptivecards.io/content/cats/1.png"
        }
      ]
    }
  ]
}

Input from @Susan Shen :

@Vikrant Singh Checked the SDK code and I’m seeing that if the text is an empty string, the SDK renderer returns null for the object, and therefore, the TextBlock is not rendered. The behavior in Web/Desktop holds in the Adaptive Card Designer as well - you can use the same payload and then select Preview Mode to see that there’s no spacing between the before and after.

I think the overall behavior should be that if the developer wants to display an empty text block, they can create one by setting the text to " " (one space) instead of an empty string.

This look like a discrepancy where for Desktop client A.C SDK Returns the null instance instead of a new line for empty strings?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (12 by maintainers)

Most upvoted comments

@shalinijoshi19 - I can only speak for Web/Desktop - the current behavior on Web/Desktop Teams is that if a TextBlock does not have any text (empty text), the TextBlock is not rendered - this seems to be the expected behavior, as the AC Designer does not render an TextBlock without empty text. The TextBlock would only render with a single whitespace, or more characters.

AFAIK, there isn’t a scenario for which we’d want TextBlocks with empty text to be rendered. This is happening on mobile, though, and it’s something we’d want to correct so that the behavior on Mobile aligns with current Web/Desktop behavior.

cc: @siduppal / @VikrantSingh01

This is actually a duplicate of the (very old) #641. 😃