feat: enhance ProductPickerField to use rawName for initial query in receipt import
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user