AdaptiveCards icon indicating copy to clipboard operation
AdaptiveCards copied to clipboard

[WPF] ChoiceSet isMultiSelect property ignored (v4.0.30319)

Open mrbrennonwilliams opened this issue 9 years ago • 11 comments

ChoiceSet has a property isMultiSelect which serves no purpose. True or False is ignored and the value array is considered to be the selected element collection.

image

If this property remains and is set to False or committed, should only the first Choice element ID be the selected element

{ "type": "AdaptiveCard", "version": "1.0", "body": [ { "type": "Input.ChoiceSet", "value": "d8cf56d0-1741-4eae-8231-6dd805f3289e , 35e1c0b7-572f-4c96-b813-7212fb671289", "style": "expanded", "choices": [ { "title": "value 1", "value": "d8cf56d0-1741-4eae-8231-6dd805f3289e" }, { "title": "value 2", "value": "35e1c0b7-572f-4c96-b813-7212fb671289" } ], "id": "cca256e5-3336-4565-9fb4-f4a3408b63ca" } ] }

mrbrennonwilliams avatar Nov 02 '17 23:11 mrbrennonwilliams

It's working for me in the latest dotnet2 branch. You were missing the "isMultiSelect": true from what you pasted

image

matthidinger avatar Nov 02 '17 23:11 matthidinger

Apologies - I don't think I explained it that well.

If you remove the isMultiSelect property, then it still stays with both checked - so in other words, isMultiSelect is set to False, and both are still selected.

mrbrennonwilliams avatar Nov 02 '17 23:11 mrbrennonwilliams

Ah that's an interesting edge case! I'm kind of on the fence on how to address this. It's really a "user error" by specifying multiple values in the card and not setting isMultiSelect to true. What would you expect the renderer to do in this case?

matthidinger avatar Nov 03 '17 00:11 matthidinger

I think it should take the first element in the array. It's kinda odd though.

I used the isMultiSelect property to also inform the designer interaction and I assume some renderers would also need it for that purpose?

mrbrennonwilliams avatar Nov 03 '17 00:11 mrbrennonwilliams

Hmm I don't think I'm 100% following your scenario with the designer. Can you provide a bit more detail?

matthidinger avatar Nov 03 '17 02:11 matthidinger

In this image you can see that the elements are correctly rendered to radiobuttons - which should only allow a single element to be "isChecked" within the group but both are still checked here

image

mrbrennonwilliams avatar Nov 03 '17 10:11 mrbrennonwilliams

I wanted to show you the UX here to perhaps make it clearer. This was a defect in the designer as well (which is why I noticed it - fix available in next version)

In this image we have a choiceset with two choices.

image

This is represented as

{ "type": "AdaptiveCard", "version": "1.0", "body": [ { "type": "Input.ChoiceSet", "value": "35e1c0b7-572f-4c96-b813-7212fb671289 , d8cf56d0-1741-4eae-8231-6dd805f3289e", "style": "expanded", "isMultiSelect": true, "choices": [ { "title": "value 1", "value": "d8cf56d0-1741-4eae-8231-6dd805f3289e" }, { "title": "value 2", "value": "35e1c0b7-572f-4c96-b813-7212fb671289" } ], "id": "cca256e5-3336-4565-9fb4-f4a3408b63ca" } ] }

PLEASE NOTE in the ChoiceSet value array, the 2nd choice is index 0

With those two choices selected, when the user now sets isMultiSelect = false, the designer immediately ensures that the index 0 element becomes the only selected element

image

This is the example of using the element property set to also change the designer UX. The designer property for choices (a listbox) switches between single and extended selection mode.

If I do not implement that in the designer, then the renderer incorrectly shows two radio boxes checked, even when isMultiSelect = false.

mrbrennonwilliams avatar Nov 03 '17 11:11 mrbrennonwilliams

The behavior I'm seeing is not consistent across renderers. This is the payload I'm using (notice in the Input.ChoiceSet, isMultiSelect is false but multiple values are specified):

{
  "type": "AdaptiveCard",
  "version": "1.0",
  "body": [
    {
      "type": "Input.ChoiceSet",
      "value": "1,3",
      "isMultiSelect": false,
      "style": "expanded",
      "choices": [
        {
          "title": "value 1",
          "value": "1"
        },
        {
          "title": "value 2",
          "value": "2"
        },
        {
          "title": "value 3",
          "value": "3"
        }
      ],
      "id": "4"
    }
  ]
}
  • NodeJS and Android: None of the choices is selected node

  • UWP and .NET HTML: The choice with the biggest value among those specified is selected uwp

  • .NET WPF: All specified choices are selected dotnet-wpf

Looks like the .NET WPF way is definitely wrong but we also need to decide which one of the first 2 is good and proceed to modify the others.

tuanh118 avatar Aug 16 '18 21:08 tuanh118

The NodeJS library is correct IMO (obviously :)) as the value provided "1,3" doesn't match any of the choice values. The contract when isMultiSelect is false is that the "value" property must match one of the choice values; specifying several values separated by a comma isn't a supported scenario. The contract is different when isMultiSelect is set to true, in which case multiple values separated by a comma is supported.

dclaux avatar Aug 16 '18 21:08 dclaux

I just tried on iOS renderer, and it doesn't display any choices, and I think not displaying the values is more consistent with what we have done with error handling. e.g. in the background color when we see bad value, we generate warnings, then replace the value with most benign value, 0.

jwoo-msft avatar Aug 17 '18 17:08 jwoo-msft

Awesome! I'll fix the UWP and .NET renderers accordingly

tuanh118 avatar Aug 17 '18 22:08 tuanh118