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

data binding to $index fails #4260

Closed
IntranetFactory opened this issue Jun 30, 2020 · 8 comments
Closed

data binding to $index fails #4260

IntranetFactory opened this issue Jun 30, 2020 · 8 comments
Labels
Area-Templating Bug Platform-JavaScript Bugs or features related to the JavaScript renderer
Projects

Comments

@IntranetFactory
Copy link

I use the following card definition in the online designer. $index in "$when": "${$index < 3}", works as expected, the 4th item is not shown. But the $index in "l${$index+1} = ${id} doesn't work, $index is always 0.

How can I use the $index of the current element in my expression?

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "Container",
            "$data":  [{"id":"l1"},{"id":"l2"},{"id":"l3"},{"id":"l4"}],
            "$when": "${$index < 3}",
            "items": [
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "type": "Column",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "l${$index+1} = ${id}",
                                    "wrap": true,
                                    "size": "Medium"
                                }
                            ],
                            "width": "stretch",
                            "verticalContentAlignment": "Center"
                        }
                    ]
                }
            ],
            "separator": true,
            "id": "first-container",
            "style": "good"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.2"
}

actual result:
image

expected result:
l1 = l1
l2 = l2
l3 = l3

@ghost ghost added the Triage-Needed label Jun 30, 2020
@ghost ghost added this to Needs triage in Bug Triage Jun 30, 2020
@dclaux
Copy link
Member

dclaux commented Jun 30, 2020

@IntranetFactory thanks for reporting. I can repro on adaptivecards.io/designer, but not locally from compiled code. I believe I fixed this bug some time ago and it's likely the web site hasn't been updated yet. @matthidinger?

@shalinijoshi19
Copy link
Member

@dclaux do you know the issue# to help track the fix?

@shalinijoshi19 shalinijoshi19 added Area-Templating Platform-JavaScript Bugs or features related to the JavaScript renderer labels Jun 30, 2020
@IntranetFactory
Copy link
Author

When I try the same card in cdn.html running on localhost preview does not work at all. I think that cdn.html uses the latest version so I couldn't verify if it's fixed in latest <script src="https://unpkg.com/adaptivecards-designer@latest/dist/adaptivecards-designer.min.js"></script>

image

@dclaux
Copy link
Member

dclaux commented Jun 30, 2020

@IntranetFactory as far as I can tell from the screenshot, you are not in preview mode, so it indeed won't work. But anyway, I am not sure a package with the fix has been published yet. The locally compiled code doesn't have the problem.

@dclaux
Copy link
Member

dclaux commented Jun 30, 2020

@shalinijoshi19 sorry, I don't. I believe it was part of a bigger set of changes.

@shalinijoshi19
Copy link
Member

@IntranetFactory we recently released the latest version of the designer which should have these fixes - can you please try the latest version at https://www.npmjs.com/package/adaptivecards-designer and let us know if you continue to see this issue? Thanks!

@shalinijoshi19 shalinijoshi19 moved this from Needs triage to Closed in Bug Triage Jul 10, 2020
@IntranetFactory
Copy link
Author

It works now. Thank you.

@microsoft microsoft deleted a comment Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Templating Bug Platform-JavaScript Bugs or features related to the JavaScript renderer
Projects
No open projects
Bug Triage
  
Closed
Development

No branches or pull requests

3 participants