-
Notifications
You must be signed in to change notification settings - Fork 47
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
Allow Modal
to keep open by adding preventHideOnOutsideClick
property
#1617
Allow Modal
to keep open by adding preventHideOnOutsideClick
property
#1617
Conversation
🦋 Changeset detectedLatest commit: fb05843 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1617 +/- ##
==========================================
+ Coverage 87.00% 87.02% +0.01%
==========================================
Files 281 281
Lines 3879 3884 +5
Branches 817 820 +3
==========================================
+ Hits 3375 3380 +5
Misses 430 430
Partials 74 74
☔ View full report in Codecov by Sentry. |
Chromatic Report🚀 Congratulations! Your build was successful! |
onPointerDownOutside={(e) => { | ||
if (preventHideOnOutsideClick) { | ||
e.preventDefault() | ||
} | ||
}} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
radix-ui AlertDialog를 참고: onInteractOutside
이벤트도 preventDefault 처리되면 좋을 거 같습니다.
preventInteractOutside
..? 기존 이름이 동작을 더 구체적으로 나타내서 좋긴 한 거 같은데 말이죠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preventInteractOutside
라 하면 이게 false 일 때 모달 밖에 있는 버튼과 interact 가능하다는 의미로 받아들여지지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그럴 수 있을 거 같고, interact outside 라면 hide on outside click -> interact outside 로 생각을 2단계 거쳐야하는 느낌이라 처음에 작성해주신 속성명이 더 좋은 거 같아요
@@ -40,6 +41,7 @@ export const ModalContent = forwardRef(function ModalContent({ | |||
...rest | |||
}: ModalContentProps, forwardedRef: React.Ref<HTMLDivElement>) { | |||
const [contentContainer, setContentContainer] = useState<HTMLElement>() | |||
const preventHideOnOutsideClick = useModalContext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ModalContent
의 속성으로 전달해줘도 되지 않을까요? Modal
의 컨텍스트로 전달해주신 이유가 궁금합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
모달이 열리고 닫히는 동작을 제어하는 속성이라서 모달의 상태나 핸들러(show
, onShow
등등)과 같은 곳에 위치하는게 적절할 것 같았습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DialogPrimitive
의 인터페이스를 따르는 게 전체적인 일관성에 있어서 더 좋지 않을까 생각했어요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인터랙션 테스트 추가 부탁드립니다!
it('should keep modal open when the user clicks outside of the modal if preventHideOnOutsideClick property is true', async () => { | ||
const { queryByRole, container } = renderOpenedModal({ | ||
modalProps: { | ||
preventHideOnOutsideClick: true, | ||
defaultShow: true, | ||
}, | ||
}) | ||
await user.click(container) | ||
expect(queryByRole('dialog')).toBeInTheDocument() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
onPointerDownOutside={(e) => { | ||
if (preventHideOnOutsideClick) { | ||
e.preventDefault() | ||
} | ||
}} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그럴 수 있을 거 같고, interact outside 라면 hide on outside click -> interact outside 로 생각을 2단계 거쳐야하는 느낌이라 처음에 작성해주신 속성명이 더 좋은 거 같아요
7dc945f
to
fb05843
Compare
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @channel.io/bezier-react@1.13.0 ### Minor Changes - Add `preventHideOnOutsideClick` property to `Modal` component ([#1617](#1617)) by @yangwooseong ### Patch Changes - Fixes an issue where the height of `TextArea` component is not specified correctly. Modify the build settings to match the package.json exports fields change in 8.5.0 of `react-textarea-autosize`. ([#1637](#1637)) by @sungik-choi - Add `ProgressBarSize`, `ProgressBarVariant` string literal type and deprecate enum ([#1595](#1595)) by @Dogdriip ## bezier-figma-plugin@0.4.1 ### Patch Changes - Updated dependencies - @channel.io/bezier-react@1.13.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Self Checklist
Related Issue
title
,subtitle
,closeIcon
inModalHeader
#1457Summary
preventHideOnOutsideClick
속성을Modal
컴포넌트 인터페이스에 추가해서, 모달 밖을 클릭해도 모달이 닫히지 않게 할 수 있도록 합니다.Details
Dialog.Content
의onPointerDownOutside
콜백에서 이벤트 전파를 막는 것으로 구현하였습니다.Breaking change? (Yes/No)
References
title
,subtitle
,closeIcon
inModalHeader
#1457Dialog.Content