From aa0b3a27788ad4d11ab7caf388932b798ea34255 Mon Sep 17 00:00:00 2001 From: Cao Hoang <65607230+cnhhoang850@users.noreply.github.com> Date: Sat, 4 Jan 2025 04:20:59 +0700 Subject: [PATCH] fix: improve useInViewObserver hook to trigger when observer is already in view on mount (#18455) --- packages/ui/components/apps/AllApps.tsx | 50 ++++++++++--------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/packages/ui/components/apps/AllApps.tsx b/packages/ui/components/apps/AllApps.tsx index 2df70fa884..8543c7de45 100644 --- a/packages/ui/components/apps/AllApps.tsx +++ b/packages/ui/components/apps/AllApps.tsx @@ -2,12 +2,10 @@ import { useAutoAnimate } from "@formkit/auto-animate/react"; import type { AppCategories } from "@prisma/client"; -import { usePathname, useRouter } from "next/navigation"; import type { UIEvent } from "react"; import { useEffect, useRef, useState } from "react"; import { classNames } from "@calcom/lib"; -import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import type { UserAdminTeams } from "@calcom/lib/server/repository/user"; import type { AppFrontendPayload as App } from "@calcom/types/App"; @@ -59,14 +57,13 @@ interface CategoryTabProps { selectedCategory: string | null; categories: string[]; searchText?: string; + onCategoryChange: (category: string | null) => void; } -function CategoryTab({ selectedCategory, categories, searchText }: CategoryTabProps) { - const pathname = usePathname(); - const searchParams = useCompatSearchParams(); +function CategoryTab({ selectedCategory, categories, searchText, onCategoryChange }: CategoryTabProps) { const { t } = useLocale(); - const router = useRouter(); const { ref, calculateScroll, leftVisible, rightVisible } = useShouldShowArrows(); + const handleLeft = () => { if (ref.current) { ref.current.scrollLeft -= 100; @@ -78,6 +75,7 @@ function CategoryTab({ selectedCategory, categories, searchText }: CategoryTabPr ref.current.scrollLeft += 100; } }; + return (

@@ -90,7 +88,7 @@ function CategoryTab({ selectedCategory, categories, searchText }: CategoryTabPr })}

{leftVisible && ( -