diff --git a/app/lib/features/geckoview/features/browser/presentation/widgets/sheets/view_tabs.dart b/app/lib/features/geckoview/features/browser/presentation/widgets/sheets/view_tabs.dart index 40918f53..5d31e5af 100644 --- a/app/lib/features/geckoview/features/browser/presentation/widgets/sheets/view_tabs.dart +++ b/app/lib/features/geckoview/features/browser/presentation/widgets/sheets/view_tabs.dart @@ -456,38 +456,36 @@ class ViewTabsSheetWidget extends HookConsumerWidget { ); final lastScroll = useRef(null); - final scrollControllerIsAttached = useListenableSelector( - sheetScrollController, - () => sheetScrollController.hasClients, - ); useEffect(() { - if (scrollControllerIsAttached) { - if (lastScroll.value != activeTab) { - final index = filteredTabEntities.value.indexWhere( - (entity) => entity.tabId == activeTab, - ); + WidgetsBinding.instance.addPostFrameCallback((_) { + if (sheetScrollController.hasClients) { + if (lastScroll.value != activeTab) { + final index = filteredTabEntities.value.indexWhere( + (entity) => entity.tabId == activeTab, + ); - if (index > -1) { - final offset = (index ~/ 2) * itemHeight; + if (index > -1) { + final offset = (index ~/ 2) * itemHeight; - if (offset != sheetScrollController.offset) { - lastScroll.value = activeTab; + if (offset != sheetScrollController.offset) { + lastScroll.value = activeTab; - unawaited( - sheetScrollController.animateTo( - offset, - duration: const Duration(milliseconds: 200), - curve: Curves.easeInOut, - ), - ); + unawaited( + sheetScrollController.animateTo( + offset, + duration: const Duration(milliseconds: 200), + curve: Curves.easeInOut, + ), + ); + } } } } - } + }); return null; - }, [filteredTabEntities, activeTab, scrollControllerIsAttached]); + }, [filteredTabEntities, activeTab]); final tabs = useMemoized(() { return [