dont override text in find in page

This commit is contained in:
Fabian Freund
2026-02-02 04:34:41 +01:00
parent e8af5f8171
commit 42911adfe1
2 changed files with 6 additions and 15 deletions
@@ -598,7 +598,7 @@ class BrowserScreen extends HookConsumerWidget {
if (tabId == null) {
return const SizedBox.shrink();
}
return FindInPageWidget(tabId: tabId);
return FindInPageWidget(key: ValueKey(tabId), tabId: tabId);
},
),
),
@@ -31,7 +31,11 @@ class FindInPageWidget extends HookConsumerWidget {
/// The height of the find-in-page widget.
static const findInPageHeight = 56.0;
const FindInPageWidget({required this.tabId, this.padding = EdgeInsets.zero});
const FindInPageWidget({
required this.tabId,
this.padding = EdgeInsets.zero,
super.key,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
@@ -45,19 +49,6 @@ class FindInPageWidget extends HookConsumerWidget {
text: searchResult?.lastSearchText ?? findInPageState.lastSearchText,
);
// Update controller text when search result changes from external sources
// (e.g., when navigating between matches)
useEffect(() {
final currentText = textController.text;
final newText =
searchResult?.lastSearchText ?? findInPageState.lastSearchText ?? '';
if (currentText != newText) {
textController.text = newText;
}
return null;
}, [searchResult?.lastSearchText, findInPageState.lastSearchText]);
// Create debouncer with automatic disposal
final debouncer = useDebouncer(const Duration(milliseconds: 300));