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

Action.ToggleVisibility does not trigger an onAction event #8711

Closed
aboultonhumana opened this issue Oct 16, 2023 · 4 comments
Closed

Action.ToggleVisibility does not trigger an onAction event #8711

aboultonhumana opened this issue Oct 16, 2023 · 4 comments

Comments

@aboultonhumana
Copy link

Target Application

Viva Connections Dashboard

Application Operating System

Windows

Schema Version

1.5

Problem Description

Setting an action of Action.ToggleVisibility in the Quick View JSON does not trigger the onAction event in SPFx code.

Expected Outcome

Expecting the Action.ToggleVisibility action to trigger an onAction even in the same way that Action.Submit and Action.Execute trigger the event.

Actual Outcome

onAction event is not triggered.

Card JSON

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5",
    "body": [
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.ToggleVisibility",
                    "title": "Toggle visibility",
                    "id": "ToggleButton",
                    "targetElements": [
                        "hidden"
                    ]
                }
            ]
        },
        {
            "type": "TextBlock",
            "text": "Initially hidden content",
            "wrap": true,
            "id": "hidden",
            "isVisible": false
        }
    ]
}

Repro Steps

  • Implement the Quick View template above
  • In code, listen for the onAction event.
@jwoo-msft
Copy link
Member

@aboultonhumana,

Have you tried using your JSON in the designer? I didn't find any issues there.
I'm closing this issue. Please respond to this thread if you have any further questions.

@aboultonhumana
Copy link
Author

@aboultonhumana,

Have you tried using your JSON in the designer? I didn't find any issues there. I'm closing this issue. Please respond to this thread if you have any further questions.

Correct, Action.ToggleVisibility triggers the action event (i.e. pops up the alert with the data) in the Designer tool but not in SharePoint Framework (v 1.18 and tested with earlier versions). The other universal actions do trigger the event in code.

@jwoo-msft
Copy link
Member

@aboultonhumana, Have you spoken with the developers who maintain SharePoint Framework? As demonstrated, Adaptive Cards are functioning correctly, as the designer is running on the latest version of Adaptive Cards.

@aboultonhumana
Copy link
Author

Thanks @jwoo-msft -- agreed it's an issue with the SPFx implementation. For anyone stumbling upon this, a workaround is to not use the ToggleVisibility action, but instead to use Action.Execute in combination with the $when attribute in the JSON template to show/hide the element based on a value stored in the card's state (e.g. a value of ${showTheThing} that is initially false). So, instead of setting a ToggleVisibility action on an element, use Action.Execute in combination with a verb used to identify that specific interaction. Then, for the Execute action, the onAction event handler in the SPFx ACE code is triggered. When that specific Action + verb occurs we then update the card's state corresponding to the $when condition, e.g. setting the showTheThing to true to conditionally show the element(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed
Development

No branches or pull requests

2 participants