refactor(edit-dialog): improve category selection handling in AI suggestion

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Nils-Johan Gynther
2026-05-03 15:03:17 +02:00
parent 842561d2b8
commit dc74a9448b
@@ -349,6 +349,7 @@ class _EditDialogState extends State<_EditDialog> {
void _applyAiSuggestionForExistingSelection() {
final suggestedId = widget.item.suggestedProductId;
int? preselectedCategoryId = widget.item.categorySuggestionId;
if (suggestedId != null) {
setState(() {
_productId = suggestedId;
@@ -360,11 +361,11 @@ class _EditDialogState extends State<_EditDialog> {
_categoryPathForCategoryId(_productCategoryId) ?? widget.item.categorySuggestionPath;
_productCategorySource = CategorySelectionSource.ai;
});
return;
preselectedCategoryId = _productCategoryId;
}
_openExistingCategoryPicker(
preselectedCategoryId: widget.item.categorySuggestionId,
preselectedCategoryId: preselectedCategoryId,
);
}
@@ -634,7 +635,9 @@ class _EditDialogState extends State<_EditDialog> {
backgroundColor: Colors.green.shade50,
side: BorderSide(color: Colors.green.shade300),
visualDensity: VisualDensity.compact,
onPressed: _applyAiSuggestionForExistingSelection,
onPressed: () => _openExistingCategoryPicker(
preselectedCategoryId: item.categorySuggestionId,
),
),
],
],