dont clear text on bang switch

This commit is contained in:
Fabian Freund
2026-05-26 05:59:34 +02:00
parent ec34a28c13
commit 8aecc92eab
@@ -289,23 +289,17 @@ class _BangChipsList extends HookConsumerWidget {
} }
void _handleSelection(BuildContext context, WidgetRef ref, BangData bang) { void _handleSelection(BuildContext context, WidgetRef ref, BangData bang) {
// Text clearing logic: // Only clear text when it parses as a URL — searching a URL via a bang
// - Site tab (domain != null): only clear if text is a valid URL // makes no sense. Otherwise preserve the query so the user can run it
// - All tab (domain == null): always clear (same as original BangChips) // against the newly selected provider.
if (domain == null) { final hasSupportedScheme =
// All tab / new tab mode - always clear uri_parser
searchTextController.clear(); .tryParseUrl(searchTextController.text)
} else { .mapNotNull((uri) => uri.hasSupportedScheme) ??
// Site tab - only clear if text is a valid URL false;
final hasSupportedScheme =
uri_parser
.tryParseUrl(searchTextController.text)
.mapNotNull((uri) => uri.hasSupportedScheme) ??
false;
if (hasSupportedScheme) { if (hasSupportedScheme) {
searchTextController.clear(); searchTextController.clear();
}
} }
// Clear the OTHER provider for mutual exclusion // Clear the OTHER provider for mutual exclusion