-
Notifications
You must be signed in to change notification settings - Fork 3
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) : 드롭다운 외부클릭 시 닫기 기능을 추가합니다. #139
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
49d4a0b
Merge pull request #136 from Yangjaecheon-Otter-Guardians/fix/rounded…
da-in d254a47
fix(dropdown) : 드롭다운 팝오버 동작추가
caseBread 17ded53
chore(dropdown) : 미사용 import 제거
caseBread c0f76a0
feat(dropdown) : 컬러픽커에도 외부클릭 닫힘기능 적용
caseBread 44edcd8
chore(dropdown) : 컨벤션 수정
caseBread File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useEffect } from 'react'; | ||
|
||
type TProps = { | ||
className?: string; | ||
children: React.ReactNode; | ||
onClose: () => void; | ||
}; | ||
|
||
const Popover: React.FC<TProps> = ({ className, children, onClose }) => { | ||
const wrapperRef = React.useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
const handleClickOutside = (event: MouseEvent) => { | ||
if (wrapperRef.current && !wrapperRef.current.contains(event.target as Node)) { | ||
onClose(); | ||
} | ||
}; | ||
|
||
document.addEventListener('mousedown', handleClickOutside); | ||
return () => { | ||
document.removeEventListener('mousedown', handleClickOutside); | ||
}; | ||
}, [wrapperRef]); | ||
|
||
return ( | ||
<div ref={wrapperRef} className={className}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Popover; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
컴포넌트 props 타이핑이 컴포넌트마다 조금씩 상이해서, 컨벤션을 정해도 좋겠네요🤔
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.
아니 체다 저 멘션도 안걸었는데 작업한지 어케 아신건지 ㅋㅋㅋㅋ 칼리뷰 정말 감사합니다 🥹🙇♂️
props 타이핑이
React.FC<TProps>
요부분이죠?저거 회사컨벤션이라 무의식중에 사용된것 같아요😅
심플썸네일에서 컨벤션이 따로 없지만, 심플썸네일에서 자주쓰는 방식으로 변경해두겠슴다!
추후 컨벤션을 정해봐도 좋을것같아요