fixed some params and ui

This commit is contained in:
Jelaletdin12
2026-08-25 22:58:08 +05:00
parent f00d2abcac
commit f293806d96
25 changed files with 547 additions and 87 deletions

View File

@@ -79,13 +79,23 @@ export function InfiniteSelect({
onChange?.("");
};
const loadingRef = useRef(false);
// Reset loading ref when the query transitions out of loading state
useEffect(() => {
if (!isLoadingMore) {
loadingRef.current = false;
}
}, [isLoadingMore]);
// ── Infinite scroll: load more when the sentinel becomes visible ──
useEffect(() => {
if (!open || !sentinelRef.current || !hasNextPage || isLoadingMore) return;
const el = sentinelRef.current;
const observer = new IntersectionObserver(
(entries) => {
if (entries[0]?.isIntersecting && hasNextPage && !isLoadingMore) {
if (entries[0]?.isIntersecting && hasNextPage && !isLoadingMore && !loadingRef.current) {
loadingRef.current = true;
onLoadMore?.();
}
},