(
leave="transition-all ease-linear"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 -translate-y-1"
- ref={containerRef}
+ ref={(r) => {
+ containerRef.current = r as HTMLDivElement;
+ if (ref && typeof ref === "object") {
+ ref.current = r as HTMLDivElement;
+ }
+ }}
onScroll={onScroll}
>
diff --git a/packages/next-admin/src/hooks/useCloseOnOutsideClick.ts b/packages/next-admin/src/hooks/useCloseOnOutsideClick.ts
index 94baf397..ff4e4041 100644
--- a/packages/next-admin/src/hooks/useCloseOnOutsideClick.ts
+++ b/packages/next-admin/src/hooks/useCloseOnOutsideClick.ts
@@ -12,7 +12,15 @@ const useClickOutside = (
}
};
- document.addEventListener("click", handleClickOutside);
+ setTimeout(() => {
+ /**
+ * There is a weird behavior on Page Router where this triggers
+ * just when a selector is opened. I suppose this is because the click event is not finished
+ * dispatching when we click on a trigger, but this is strange that
+ * this does not occur in App Router
+ */
+ document.addEventListener("click", handleClickOutside);
+ });
return () => {
document.removeEventListener("click", handleClickOutside);
};