diff --git a/.storybook/preview-body.html b/.storybook/preview-body.html
index 57e7030b..bd3b82dc 100644
--- a/.storybook/preview-body.html
+++ b/.storybook/preview-body.html
@@ -1,4 +1,2 @@
-
-
diff --git a/src/components/Dropdown/components/DropdownList.tsx b/src/components/Dropdown/components/DropdownList.tsx
index 24311c7d..f231e89c 100644
--- a/src/components/Dropdown/components/DropdownList.tsx
+++ b/src/components/Dropdown/components/DropdownList.tsx
@@ -1,31 +1,25 @@
import { type PropsWithChildren } from 'react';
import { assignInlineVars } from '@vanilla-extract/dynamic';
-import Portal from '@components/Portal';
-import { PORTAL_ID } from '@constants/portal';
-
import { useDropdownContext } from '..';
import * as styles from '../style.css';
const DropdownList = ({ children }: PropsWithChildren) => {
- const { size, targetRef, position, fixed, isOpen } = useDropdownContext();
+ const { isOpen, targetRef, size, position } = useDropdownContext();
return (
<>
{isOpen && (
-
-
-
+
)}
>
);
diff --git a/src/components/Dropdown/index.tsx b/src/components/Dropdown/index.tsx
index 29a30c56..6a5244ef 100644
--- a/src/components/Dropdown/index.tsx
+++ b/src/components/Dropdown/index.tsx
@@ -28,8 +28,6 @@ interface DropdownContextProps {
position: typeof INIT_POSITION;
/** dropdown menulist 요소의 ref 객체 */
targetRef: RefObject;
- /** dropdown menulist css position fixed 적용 여부 */
- fixed?: boolean;
/** dropdown menulist 열림, 닫힘 상태 */
isOpen: boolean;
/** dropdown trigger toggle 함수 */
@@ -38,7 +36,7 @@ interface DropdownContextProps {
interface DropdownRootProps
extends HTMLAttributes,
- Pick {
+ Pick {
className?: HTMLAttributes['className'];
}
@@ -48,19 +46,17 @@ const DropdownRoot = ({
children,
size = 'small',
placement = 'bottom-left',
- fixed = false,
...props
}: PropsWithChildren) => {
const { isOpen, onClose, onToggle } = useDisclosure();
const dropdownRef = useClickAway({
onClickAway: onClose,
- });
+ })!;
const { targetRef, position } = usePosition(
{
defaultTriggerRef: dropdownRef,
isOpen,
placement,
- fixed,
},
);
@@ -71,7 +67,6 @@ const DropdownRoot = ({
placement,
position,
targetRef,
- fixed,
isOpen,
onToggle,
}}
diff --git a/src/components/Dropdown/style.css.ts b/src/components/Dropdown/style.css.ts
index 4127e315..b4a46f42 100644
--- a/src/components/Dropdown/style.css.ts
+++ b/src/components/Dropdown/style.css.ts
@@ -14,13 +14,12 @@ export const trigger = style({
width: 'fit-content',
});
-export const position = createVar();
export const top = createVar();
export const left = createVar();
export const menuList = recipe({
base: {
- position,
+ position: 'absolute',
top,
left,
marginTop: '4px',
diff --git a/src/components/Layout/components/ProfileButton.tsx b/src/components/Layout/components/ProfileButton.tsx
index 6efa0487..870336c7 100644
--- a/src/components/Layout/components/ProfileButton.tsx
+++ b/src/components/Layout/components/ProfileButton.tsx
@@ -26,7 +26,6 @@ const ProfileButton = () => {
className={styles.dialogWrapper}
size="medium"
placement="bottom-right"
- fixed
>
diff --git a/src/components/Tooltip/components/TooltipContent.tsx b/src/components/Tooltip/components/TooltipContent.tsx
index 4a9547c1..8594b95d 100644
--- a/src/components/Tooltip/components/TooltipContent.tsx
+++ b/src/components/Tooltip/components/TooltipContent.tsx
@@ -2,9 +2,6 @@ import type { PropsWithChildren } from 'react';
import { assignInlineVars } from '@vanilla-extract/dynamic';
import clsx from 'clsx';
-import { PORTAL_ID } from '@constants/portal';
-
-import Portal from '../../Portal';
import { useTooltipContext } from '..';
import * as styles from '../style.css';
@@ -28,23 +25,21 @@ const TooltipContent = ({ children }: PropsWithChildren) => {
return (
<>
{isOpen && (
-
-
- {children}
-
-
+
+ {children}
+
)}
>
);
diff --git a/src/components/Tooltip/index.tsx b/src/components/Tooltip/index.tsx
index 12353b11..1d9d2662 100644
--- a/src/components/Tooltip/index.tsx
+++ b/src/components/Tooltip/index.tsx
@@ -6,6 +6,7 @@ import usePosition from '@hooks/usePosition';
import TooltipContent from './components/TooltipContent';
import TooltipTrigger from './components/TooltipTrigger';
+import * as styles from './style.css';
const INIT_POSITION = { top: 0, left: 0 };
@@ -51,7 +52,9 @@ const TooltipRoot = ({
onClose,
}}
>
- {children}
+
+ {children}
+
);
};
diff --git a/src/components/Tooltip/style.css.ts b/src/components/Tooltip/style.css.ts
index a727dfe5..91185107 100644
--- a/src/components/Tooltip/style.css.ts
+++ b/src/components/Tooltip/style.css.ts
@@ -4,6 +4,10 @@ import { recipe } from '@vanilla-extract/recipes';
import { sprinkles } from '@styles/sprinkles.css';
import { COLORS, Z_INDEX } from '@styles/tokens';
+export const wrapper = style({
+ position: 'relative',
+});
+
export const trigger = style({
width: 'fit-content',
height: 'fit-content',
diff --git a/src/constants/portal.ts b/src/constants/portal.ts
index cfccd0c4..16280c8a 100644
--- a/src/constants/portal.ts
+++ b/src/constants/portal.ts
@@ -1,6 +1,4 @@
export const PORTAL_ID = {
MODAL: 'modal-root',
TOAST: 'toast-root',
- TOOLTIP: 'tooltip-root',
- DROPDOWN: 'dropdown-root',
} as const;
diff --git a/src/hooks/usePosition.ts b/src/hooks/usePosition.ts
index 67d96f85..c09a5b23 100644
--- a/src/hooks/usePosition.ts
+++ b/src/hooks/usePosition.ts
@@ -25,6 +25,7 @@ const usePosition = <
const ref = useRef(null);
const triggerRef = defaultTriggerRef || ref;
const targetRef = useRef(null);
+
const [position, setPosition] = useState(POSITION);
useEffect(() => {
@@ -32,23 +33,16 @@ const usePosition = <
return;
}
- const {
- x,
- y,
- bottom: triggerBottom,
- width: triggerWidth,
- height: triggerHeight,
- } = triggerRef.current.getBoundingClientRect();
+ const { width: triggerWidth, height: triggerHeight } =
+ triggerRef.current.getBoundingClientRect();
const { width: targetWidth } = targetRef.current.getBoundingClientRect();
- const { scrollX, scrollY } = window;
-
- const top = y + scrollY - triggerHeight;
- const bottom = !fixed ? y + scrollY + triggerHeight : triggerBottom;
+ const top = -triggerHeight;
+ const bottom = triggerHeight;
- const left = x + scrollX;
- const center = left + triggerWidth / 2 - targetWidth / 2;
- const right = left + triggerWidth - targetWidth;
+ const left = 0;
+ const center = triggerWidth / 2 - targetWidth / 2;
+ const right = triggerWidth - targetWidth;
const CALCULATED_POSITION: Record = {
'top-left': { top, left },