Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix(mobile): lost initial scroll position on empty ai chat page (#6895)

Richard Shiue0cba3f9e3fe5
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart
index ac9536632c..6c3dd4bd4d 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart
@@ -180,7 +180,7 @@ class WelcomeSampleQuestion extends StatelessWidget {
}
}
-class _AutoScrollingSampleQuestions extends StatelessWidget {
+class _AutoScrollingSampleQuestions extends StatefulWidget {
const _AutoScrollingSampleQuestions({
super.key,
required this.questions,
@@ -194,17 +194,29 @@ class _AutoScrollingSampleQuestions extends StatelessWidget {
final double offset;
final bool reverse;
+ @override
+ State<_AutoScrollingSampleQuestions> createState() =>
+ _AutoScrollingSampleQuestionsState();
+}
+
+class _AutoScrollingSampleQuestionsState
+ extends State<_AutoScrollingSampleQuestions> {
+ late final scrollController = ScrollController(
+ initialScrollOffset: widget.offset,
+ );
+
@override
Widget build(BuildContext context) {
return SizedBox(
height: 36,
child: InfiniteScrollView(
+ scrollController: scrollController,
centerKey: UniqueKey(),
- itemCount: questions.length,
+ itemCount: widget.questions.length,
itemBuilder: (context, index) {
return WelcomeSampleQuestion(
- question: questions[index],
- onSelected: onSelected,
+ question: widget.questions[index],
+ onSelected: widget.onSelected,
);
},
separatorBuilder: (context, index) => const HSpace(8),