From bbdd9d713cd3555f8b8aba3d50577bd8f2b317e9 Mon Sep 17 00:00:00 2001 From: Ryo Matsukawa <76232929+ryo-manba@users.noreply.github.com> Date: Mon, 30 Dec 2024 15:14:30 +0900 Subject: [PATCH] fix: type error --- packages/components/popover/src/use-popover.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/components/popover/src/use-popover.ts b/packages/components/popover/src/use-popover.ts index 22aa39dc3e..074081000b 100644 --- a/packages/components/popover/src/use-popover.ts +++ b/packages/components/popover/src/use-popover.ts @@ -81,6 +81,8 @@ export interface Props extends HTMLNextUIProps<"div"> { onClose?: () => void; } +const DEFAULT_PLACEMENT = "top"; + export type UsePopoverProps = Props & Omit & OverlayTriggerProps & @@ -110,7 +112,7 @@ export function usePopover(originalProps: UsePopoverProps) { portalContainer, updatePositionDeps, dialogProps: dialogPropsProp, - placement: placementProp = "top", + placement: placementProp = DEFAULT_PLACEMENT, triggerType = "dialog", showArrow = false, offset = 7, @@ -204,7 +206,7 @@ export function usePopover(originalProps: UsePopoverProps) { "data-focus": dataAttr(isFocused), "data-arrow": dataAttr(showArrow), "data-focus-visible": dataAttr(isFocusVisible), - "data-placement": getArrowPlacement(placement || "top", placementProp), + "data-placement": getArrowPlacement(placement || DEFAULT_PLACEMENT, placementProp), ...mergeProps(focusProps, dialogPropsProp, props), className: slots.base({class: clsx(baseStyles)}), style: { @@ -218,7 +220,7 @@ export function usePopover(originalProps: UsePopoverProps) { "data-slot": "content", "data-open": dataAttr(state.isOpen), "data-arrow": dataAttr(showArrow), - "data-placement": getArrowPlacement(placement || "top", placementProp), + "data-placement": getArrowPlacement(placement || DEFAULT_PLACEMENT, placementProp), className: slots.content({class: clsx(classNames?.content, props.className)}), }), [slots, state.isOpen, showArrow, placement, placementProp, classNames], @@ -305,7 +307,7 @@ export function usePopover(originalProps: UsePopoverProps) { classNames, showArrow, triggerRef, - placement, + placement: placement || DEFAULT_PLACEMENT, isNonModal, popoverRef: domRef, portalContainer,