From 77950e48c76f4a3b29d01831d43039caba29888a Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期二, 18 十一月 2025 14:12:42 +0800
Subject: [PATCH] 修改
---
app/components/base/portal-to-follow-elem/index.tsx | 40 +++++++++++-----------------------------
1 files changed, 11 insertions(+), 29 deletions(-)
diff --git a/app/components/base/portal-to-follow-elem/index.tsx b/app/components/base/portal-to-follow-elem/index.tsx
index 1e2e198..4a380e6 100644
--- a/app/components/base/portal-to-follow-elem/index.tsx
+++ b/app/components/base/portal-to-follow-elem/index.tsx
@@ -6,7 +6,6 @@
flip,
offset,
shift,
- size,
useDismiss,
useFloating,
useFocus,
@@ -28,7 +27,6 @@
open?: boolean
offset?: number | OffsetOptions
onOpenChange?: (open: boolean) => void
- triggerPopupSameWidth?: boolean
}
export function usePortalToFollowElem({
@@ -36,7 +34,6 @@
open,
offset: offsetValue = 0,
onOpenChange: setControlledOpen,
- triggerPopupSameWidth,
}: PortalToFollowElemOptions = {}) {
const setOpen = setControlledOpen
@@ -53,12 +50,6 @@
padding: 5,
}),
shift({ padding: 5 }),
- size({
- apply({ rects, elements }) {
- if (triggerPopupSameWidth)
- elements.floating.style.width = `${rects.reference.width}px`
- },
- }),
],
})
@@ -114,16 +105,12 @@
)
}
-export const PortalToFollowElemTrigger = (
- {
- ref: propRef,
- children,
- asChild = false,
- ...props
- }: React.HTMLProps<HTMLElement> & { ref?: React.RefObject<HTMLElement>, asChild?: boolean },
-) => {
+export const PortalToFollowElemTrigger = React.forwardRef<
+HTMLElement,
+React.HTMLProps<HTMLElement> & { asChild?: boolean }
+>(({ children, asChild = false, ...props }, propRef) => {
const context = usePortalToFollowElemContext()
- const childrenRef = (children as any).props?.ref
+ const childrenRef = (children as any).ref
const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef])
// `asChild` allows the user to pass any element as the anchor
@@ -150,18 +137,13 @@
{children}
</div>
)
-}
+})
PortalToFollowElemTrigger.displayName = 'PortalToFollowElemTrigger'
-export const PortalToFollowElemContent = (
- {
- ref: propRef,
- style,
- ...props
- }: React.HTMLProps<HTMLDivElement> & {
- ref?: React.RefObject<HTMLDivElement>;
- },
-) => {
+export const PortalToFollowElemContent = React.forwardRef<
+HTMLDivElement,
+React.HTMLProps<HTMLDivElement>
+>(({ style, ...props }, propRef) => {
const context = usePortalToFollowElemContext()
const ref = useMergeRefs([context.refs.setFloating, propRef])
@@ -182,6 +164,6 @@
/>
</FloatingPortal>
)
-}
+})
PortalToFollowElemContent.displayName = 'PortalToFollowElemContent'
--
Gitblit v1.8.0