From 5bfbf3dd27028fe4f97107037f737375409c6643 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Thu, 1 Jan 2026 16:37:18 -0800 Subject: [PATCH] Fix radio button inference for modifier groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Infer radio button behavior when group has exactly one default-checked item - Both visual (Radio widget) and behavior (_toggleSelection) now consistent - Fixes issue where selecting different option kept both default and selected 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- lib/screens/menu_browse_screen.dart | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/screens/menu_browse_screen.dart b/lib/screens/menu_browse_screen.dart index 531d9cf..2d2e9df 100644 --- a/lib/screens/menu_browse_screen.dart +++ b/lib/screens/menu_browse_screen.dart @@ -1058,9 +1058,16 @@ class _ItemCustomizationSheetState extends State<_ItemCustomizationSheet> { Widget _buildSelectionWidget(MenuItem item, MenuItem parent) { final isSelected = _selectedItemIds.contains(item.itemId); + final siblings = widget.itemsByParent[parent.itemId] ?? []; - // Radio button if max selection is 1 - if (parent.maxNumSelectionReq == 1) { + // Determine if this should behave as a radio button group: + // 1. Explicit: maxNumSelectionReq == 1 + // 2. Inferred: Group has exactly one default-checked item (implies single selection) + final isRadioGroup = parent.maxNumSelectionReq == 1 || + (siblings.where((s) => s.isCheckedByDefault).length == 1 && + siblings.every((s) => !s.requiresChildSelection)); + + if (isRadioGroup) { return Radio( value: item.itemId, groupValue: _getSelectedInGroup(parent.itemId), @@ -1090,10 +1097,17 @@ class _ItemCustomizationSheetState extends State<_ItemCustomizationSheet> { _validationError = null; final isCurrentlySelected = _selectedItemIds.contains(item.itemId); + final siblings = widget.itemsByParent[parent.itemId] ?? []; - // For radio buttons (max = 1), deselect siblings and always select the clicked item - if (parent.maxNumSelectionReq == 1) { - final siblings = widget.itemsByParent[parent.itemId] ?? []; + // Determine if this should behave as a radio button group: + // 1. Explicit: maxNumSelectionReq == 1 + // 2. Inferred: Group has exactly one default-checked item (implies single selection) + final isRadioGroup = parent.maxNumSelectionReq == 1 || + (siblings.where((s) => s.isCheckedByDefault).length == 1 && + siblings.every((s) => !s.requiresChildSelection)); + + // For radio buttons, deselect siblings and always select the clicked item + if (isRadioGroup) { for (final sibling in siblings) { _selectedItemIds.remove(sibling.itemId); _deselectDescendants(sibling.itemId);