fixed some params and ui
This commit is contained in:
@@ -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?.();
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user