From 8aecc92eabcec51d475255fac76a3bed60bbe707 Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Tue, 26 May 2026 05:59:34 +0200 Subject: [PATCH] dont clear text on bang switch --- .../widgets/smart_bang_selector.dart | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/apps/weblibre/lib/features/geckoview/features/search/presentation/widgets/smart_bang_selector.dart b/apps/weblibre/lib/features/geckoview/features/search/presentation/widgets/smart_bang_selector.dart index c065c178..240a6de3 100644 --- a/apps/weblibre/lib/features/geckoview/features/search/presentation/widgets/smart_bang_selector.dart +++ b/apps/weblibre/lib/features/geckoview/features/search/presentation/widgets/smart_bang_selector.dart @@ -289,23 +289,17 @@ class _BangChipsList extends HookConsumerWidget { } void _handleSelection(BuildContext context, WidgetRef ref, BangData bang) { - // Text clearing logic: - // - Site tab (domain != null): only clear if text is a valid URL - // - All tab (domain == null): always clear (same as original BangChips) - if (domain == null) { - // All tab / new tab mode - always clear - searchTextController.clear(); - } else { - // Site tab - only clear if text is a valid URL - final hasSupportedScheme = - uri_parser - .tryParseUrl(searchTextController.text) - .mapNotNull((uri) => uri.hasSupportedScheme) ?? - false; + // Only clear text when it parses as a URL — searching a URL via a bang + // makes no sense. Otherwise preserve the query so the user can run it + // against the newly selected provider. + final hasSupportedScheme = + uri_parser + .tryParseUrl(searchTextController.text) + .mapNotNull((uri) => uri.hasSupportedScheme) ?? + false; - if (hasSupportedScheme) { - searchTextController.clear(); - } + if (hasSupportedScheme) { + searchTextController.clear(); } // Clear the OTHER provider for mutual exclusion