Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Dropdown이 열렸을 때 특정 영역 클릭 시 닫히지 않는 오류를 수정한다. #829

Merged
merged 5 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 55 additions & 51 deletions packages/vibrant-components/src/lib/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { Align, Side } from 'packages/vibrant-utils/src/types';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import {
Box,
OverlayBox,
PortalBox,
PressableBox,
ScrollBox,
ThemeProvider,
getWindowDimensions,
Expand Down Expand Up @@ -173,7 +174,7 @@ export const Dropdown = withDropdownVariation(
spacing
);

setOffset({ x: offsetX, y: offsetY });
setOffset({ x: openerRect.x + offsetX, y: openerRect.y + offsetY });
}

setContentHeight(height);
Expand Down Expand Up @@ -214,60 +215,63 @@ export const Dropdown = withDropdownVariation(
return (
<>
<Box ref={openerRef}>{opener}</Box>
{!isMobile && (
{!isMobile && isOpen && (
<ThemeProvider theme={rootThemeMode}>
{isOpen && (
<OverlayBox
open={isOpen}
onDismiss={closeDropdown}
targetRef={customOpenerRef.current ? customOpenerRef : openerRef}
zIndex={zIndex.dropdown}
<PortalBox zIndex={zIndex.dropdown} top={0} right={0} bottom={0} left={0}>
<PressableBox
as="div"
position="absolute"
cursor="default"
top={0}
right={0}
bottom={0}
left={0}
onClick={closeDropdown}
/>
<Transition
animation={{
opacity: visible ? 1 : 0,
...(visible
? {
x: offset.x,
y: offset.y,
}
: {}),
}}
style={{
x: offset.x,
y: offset.y,
}}
duration={200}
>
<Transition
animation={{
opacity: visible ? 1 : 0,
...(visible
? {
x: offset.x,
y: offset.y,
}
: {}),
}}
style={{
x: offset.x,
y: offset.y,
}}
duration={200}
>
<Box>
<Box
backgroundColor="surface2"
py={CONTENT_PADDING}
elevationLevel={4}
borderRadiusLevel={1}
minWidth={[280, 280, 240]}
<Box alignSelf="flex-start">
<Box
backgroundColor="surface2"
py={CONTENT_PADDING}
elevationLevel={4}
borderRadiusLevel={1}
minWidth={[280, 280, 240]}
>
<Transition
animation={
visible
? {
height: contentHeight,
}
: {}
}
duration={200}
>
<Transition
animation={
visible
? {
height: contentHeight,
}
: {}
}
duration={200}
>
<Box overflow="hidden" height={contentHeight}>
<Box onLayout={handleContentResize} flexShrink={0} data-testid={testId}>
{renderContents({ close: closeDropdown })}
</Box>
<Box overflow="hidden" height={contentHeight}>
<Box onLayout={handleContentResize} flexShrink={0} data-testid={testId}>
{renderContents({ close: closeDropdown })}
</Box>
</Transition>
</Box>
</Box>
</Transition>
</Box>
</Transition>
</OverlayBox>
)}
</Box>
</Transition>
</PortalBox>
</ThemeProvider>
)}
{isMobile && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ describe('<TableDateFilter />', () => {

it('should render only provided operator options', async () => {
await waitFor(() => {
expect(renderer.queryAllByText(TableFilterGroupTranslation.dateFilter.operators.equals)[1]).toBeFalsy();
expect(renderer.queryByText(TableFilterGroupTranslation.dateFilter.operators.equals)).toBeFalsy();

expect(renderer.queryByText(TableFilterGroupTranslation.dateFilter.operators.notEquals)).toBeFalsy();

expect(renderer.queryByText(TableFilterGroupTranslation.dateFilter.operators.before)).toBeTruthy();
YimJiYoung marked this conversation as resolved.
Show resolved Hide resolved
expect(renderer.queryAllByText(TableFilterGroupTranslation.dateFilter.operators.before)[1]).toBeTruthy();

expect(renderer.queryByText(TableFilterGroupTranslation.dateFilter.operators.after)).toBeFalsy();

Expand Down
Loading