Skip to content

Commit cfcd781

Browse files
authored
Merge pull request #126 from Chiman2937/dev/kcy
[HotFix]: ColorPickerModal 복사 기능 누락 건 수정
2 parents 3601def + 874a3b3 commit cfcd781

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/pages/CreateRollingPaperPage/components/ColorPickerModal.jsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@ const ColorPickerModal = ({ initialColor = '#ffffff', onSubmit, onClose }) => {
1313
setColor(e.target.value);
1414
};
1515

16-
const handleColorCopyClick = () => {
16+
const handleColorCopyClick = async () => {
1717
const isHexColor = (str) => /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(str);
18-
if (isHexColor(color)) {
19-
showToast({ type: 'success', message: '복사 성공', timer: 1000 });
20-
} else {
18+
19+
if (!isHexColor(color)) {
2120
showToast({ type: 'fail', message: '유효한 값이 아닙니다', timer: 1000 });
21+
return;
22+
}
23+
24+
try {
25+
await navigator.clipboard.writeText(color);
26+
showToast({ type: 'success', message: '복사 성공', timer: 1000 });
27+
} catch (err) {
28+
showToast({ type: 'fail', message: '복사 실패', timer: 1000 });
29+
console.error(err);
2230
}
2331
};
2432

0 commit comments

Comments
 (0)