Skip to content

Commit 351a182

Browse files
committed
fix(content): prevent text auto-selection in filter dialog
Fixes an issue where the search text in the filter dialog would become automatically selected after typing. This was caused by unnecessarily updating the `TextEditingController`'s text on every state change. The fix ensures the controller is only updated if its text differs from the BLoC state, preserving the user's cursor position and selection.
1 parent a441605 commit 351a182

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/content_management/widgets/filter_dialog/filter_dialog.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ class _FilterDialogState extends State<FilterDialog> {
104104
// so we can directly use BlocBuilder here.
105105
return BlocBuilder<FilterDialogBloc, FilterDialogState>(
106106
builder: (context, filterDialogState) {
107-
_searchController.text = filterDialogState.searchQuery;
107+
// Synchronize the controller with the state, but only if they differ.
108+
// This prevents the cursor from jumping and text from being re-selected.
109+
if (_searchController.text != filterDialogState.searchQuery) {
110+
_searchController.text = filterDialogState.searchQuery;
111+
}
108112
return Scaffold(
109113
appBar: AppBar(
110114
title: Text(_getDialogTitle(l10n)),

0 commit comments

Comments
 (0)