aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/components
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-15 18:19:09 +0000
committerMohamedBassem <me@mbassem.com>2024-03-15 18:24:17 +0000
commitc4d7223115865474f09661cdbfee60a559f4b2c2 (patch)
treee143f77f8ee0b19bcbde8170063b0cfa59b7306f /apps/mobile/components
parent77b78922e5d16eddbe2f2b8f97b4e8cef1d4f5b3 (diff)
downloadkarakeep-c4d7223115865474f09661cdbfee60a559f4b2c2.tar.zst
fix(mobile): Scroll to the top when the main tab is clicked
Diffstat (limited to 'apps/mobile/components')
-rw-r--r--apps/mobile/components/bookmarks/BookmarkList.tsx6
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/mobile/components/bookmarks/BookmarkList.tsx b/apps/mobile/components/bookmarks/BookmarkList.tsx
index e3c2bdb1..48272fb3 100644
--- a/apps/mobile/components/bookmarks/BookmarkList.tsx
+++ b/apps/mobile/components/bookmarks/BookmarkList.tsx
@@ -1,10 +1,11 @@
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { Text, View, Keyboard } from "react-native";
import Animated, { LinearTransition } from "react-native-reanimated";
import { api } from "@/lib/trpc";
import FullPageSpinner from "../ui/FullPageSpinner";
import BookmarkCard from "./BookmarkCard";
+import { useScrollToTop } from '@react-navigation/native';
export default function BookmarkList({
favourited,
@@ -17,6 +18,8 @@ export default function BookmarkList({
}) {
const apiUtils = api.useUtils();
const [refreshing, setRefreshing] = useState(false);
+ const flatListRef = useRef(null);
+ useScrollToTop(flatListRef);
const { data, isPending, isPlaceholderData } =
api.bookmarks.getBookmarks.useQuery({
favourited,
@@ -39,6 +42,7 @@ export default function BookmarkList({
return (
<Animated.FlatList
+ ref={flatListRef}
itemLayoutAnimation={LinearTransition}
contentContainerStyle={{
gap: 15,