From c18beddef853bc0d2510551fd232967fe2733e09 Mon Sep 17 00:00:00 2001 From: Tushar Harsora Date: Sun, 5 May 2024 04:14:34 +0530 Subject: [PATCH] fix(mobile): Reset dropdown values in search by location on mobile (#9261) * set derived inputs as null if source input changes * format --------- Co-authored-by: Tushar Harsora Co-authored-by: Alex Tran --- .../search/ui/search_filter/location_picker.dart | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mobile/lib/modules/search/ui/search_filter/location_picker.dart b/mobile/lib/modules/search/ui/search_filter/location_picker.dart index 46fdee289e..05b55a7403 100644 --- a/mobile/lib/modules/search/ui/search_filter/location_picker.dart +++ b/mobile/lib/modules/search/ui/search_filter/location_picker.dart @@ -87,11 +87,16 @@ class LocationPicker extends HookConsumerWidget { trailingIcon: const Icon(Icons.arrow_drop_down_rounded), selectedTrailingIcon: const Icon(Icons.arrow_drop_up_rounded), onSelected: (value) { + if (value.toString() == selectedCountry.value) { + return; + } selectedCountry.value = value.toString(); + stateTextController.value = TextEditingValue.empty; + cityTextController.value = TextEditingValue.empty; onSelected({ 'country': selectedCountry.value, - 'state': selectedState.value, - 'city': selectedCity.value, + 'state': null, + 'city': null, }); }, ), @@ -120,11 +125,15 @@ class LocationPicker extends HookConsumerWidget { trailingIcon: const Icon(Icons.arrow_drop_down_rounded), selectedTrailingIcon: const Icon(Icons.arrow_drop_up_rounded), onSelected: (value) { + if (value.toString() == selectedState.value) { + return; + } selectedState.value = value.toString(); + cityTextController.value = TextEditingValue.empty; onSelected({ 'country': selectedCountry.value, 'state': selectedState.value, - 'city': selectedCity.value, + 'city': null, }); }, ),