-
Notifications
You must be signed in to change notification settings - Fork 0
[URH-67] usePreventCopy 신규 #50
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
Conversation
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.
깔끔하게 작성하셨군요 수고하셨습니다!👍
const usePreventCopy = (callback?: () => void) => { | ||
const preventCopy = (e: ClipboardEvent) => { |
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.
[P3] 일단 처음에 백로그에 의견을제시했을때는 preventCopy라고 작성하긴 했는데... copy와 cut 모두를 차단한다는 점에서 이름을 조금 바꿔볼 필요가 있을까 싶어지네요
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.
[P3] 또한, boolean값 매개변수를 통해 조건부터 해당 이벤트를 차단하게 하면 조금 더 유연한 훅이 될 수 있지 않을까요? 디폴트는 true를 주고요. 정확하게 용도가 떠오르진 않지만 회원이면 복/잘 가능 비회원이면 복/잘 불가능 이렇게...
물론 꼭 추가되어야하는 필수 기능은 아니라고 생각합니다ㅋㅋㅋ
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.
좋은 의견 감사해요 소현 님!
- 소현 님 의견을 듣고 나니
copy
와cut
을 함께 차단할 필요가 없을 것 같다는 생각이 들기도 하네요. cut 이벤트가 발생하는 상황은 사용자에게 이미 write 권한이 주어진 상황일텐데 그런 상황에서는 굳이 막을 필요가 없다는 생각이 들었습니다.usePreventCopy
와usePreventCut
을 분리하는 건 어떻게 생각하실까요? - callback 활성화 여부는 생각하지 못한 부분인데 짚어주셔서 감사해요! 그런데 callback 활성화 여부는 외부에서 처리하는 게 좀 더 명확하지 않을까요? 현재 상태(as-is)와 소현 님이 말씀해주신 상태(to-be)를 비교해보았는데 usePreventCopy 훅은 copy 이벤트를 차단하는 역할만 가져가게 하고 싶기도 하네요!
// as-is
isAuth && usePreventCopy(callback)
// to-be
usePreventCopy(callback, isAuth)
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.
- 앗 저는 반대로
usePreventClipboard
와 같이 합쳐진 상태에서 이름을 바꿔야하는 게 아닐까 하여 제안드린거였는데 그렇게 바꿀 수도 있네요. 분리한다는 게 나쁘진 않지만 그럼 훅의 기능의 크기(?)가 너무 작아지지 않나하는 생각도 듭니다. - 알려주신 대로 외부에서 처리하는 방식도 좋아보입니다. 꼭 변수를 넘겨주면서 관리할 필요는 없으니까요
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.
저도 usePreventClipboard로 훅을 재정의하는 것을 생각해봤는데 사용자가 useClipboard를 차단하는 기능으로 오해하진 않을까 하는 생각도 같이 들었습니다. copy와 cut 이벤트는 clipboard 이벤트와는 별개의 로직이더라구요. 그래도 소현 님이 말씀해주신 방향엔 저도 동의를 해서 해당 내용은 리팩토링 시에 진행해 보겠습니다!
이 PR의 오픈 기간이 오래되어서 일단 머지를 한 번 하는 게 좋을 것 같네요. 혹시 또 다른 내용이 없다면 승인 한 번 부탁드려도 될까요?
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.
👍
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.
수고하셨습니다😀👍
👾 Pull Request
1️⃣ Spec
2️⃣ 변경 사항
없음
3️⃣ 예시 코드