Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,34 @@ final multipleChoice = CatalogItem(
}
]
''',
() => '''
[
{
"id": "root",
"component": {
"MultipleChoice": {
"selections": {
"path": "/mySelections"
},
"maxAllowedSelections": 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The maxAllowedSelections property is a great addition, but its logic doesn't seem to be implemented in the MultipleChoice widget builder.

Specifically:

  • The onChanged handler (lines 90-105) adds/removes items from the selections list without respecting maxAllowedSelections. When an item is selected, it should check if the limit is reached. If maxAllowedSelections is 1, selecting a new item should deselect any previously selected item.
  • When maxAllowedSelections is 1, it would be more intuitive to render RadioListTile widgets instead of CheckboxListTile to visually indicate that only one option can be selected.
  • Additionally, there are no tests for the maxAllowedSelections behavior. A test case should be added to verify the correct behavior when maxAllowedSelections is set, especially for the single-selection case.

Since this PR adds an example for a feature that is not yet implemented, it could be misleading. I'd recommend implementing this logic and adding tests as part of this PR, or removing this example for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true: #448

"options": [
{
"label": {
"literalString": "Radio Button 1"
},
"value": "1"
},
{
"label": {
"literalString": "Radio Button 2"
},
"value": "2"
}
]
}
}
}
]
''',
],
);
Loading