feat: enhance ProductPickerField to use rawName for initial query in receipt import

This commit is contained in:
Nils-Johan Gynther
2026-05-01 02:00:13 +02:00
parent f4fea7b92c
commit 47801935e9
2 changed files with 7 additions and 3 deletions
@@ -91,6 +91,7 @@ class ProductPickerField extends StatelessWidget {
}
Future<void> _openPicker(BuildContext context) async {
// Skapa controller utanför showSheet för att undvika reset vid rebuild
final result = await ProductPickerField.showSheet(
context,
products: products,
@@ -121,6 +122,8 @@ class ProductPickerField extends StatelessWidget {
isScrollControlled: true,
useSafeArea: true,
builder: (sheetContext) {
// Skapa controller EN gång per öppnad ark — inte inuti StatefulBuilder
final controller = TextEditingController(text: initialQuery ?? '');
var query = initialQuery ?? '';
return StatefulBuilder(
@@ -155,7 +158,7 @@ class ProductPickerField extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
child: TextField(
autofocus: true,
controller: TextEditingController(text: initialQuery ?? ''),
controller: controller,
decoration: const InputDecoration(
hintText: 'Sök produkt...',
prefixIcon: Icon(Icons.search),