[SHOPTIME-3723] Detail Page / QR 팝업 닫을 때 자바스크립트 에러

[수정파일]

  src/views/DetailPanel/SingleProduct/SingleOption.jsx

[수정내용]

  onClose가 호출 시 자바스크립트 에러가 나오고 포커스가 사라짐

[원인]

  onClose 함수에서 spotlightId값을 받아서 포커스를 해주고 있는데 spotlightId값을 보내주지 않았을 경우에 대한 예외처리가 없음

[대책]

  타입체크하여 분기처리
This commit is contained in:
고동영
2024-10-18 16:21:21 +09:00
parent 1cc1842d32
commit f5ab8bf6ff

View File

@@ -212,6 +212,26 @@ export default function SingleOption({
}
}, [productOptionInfos, selectedBtnOptIdx, isOptionValue]);
const onClose = useCallback(
(spotlightId) => {
dispatch(setHidePopup());
let currentSpot;
if (typeof spotlightId === "string") {
currentSpot = spotlightId;
} else {
currentSpot = "spotlightId_buynowBtn";
}
if (currentSpot) {
setTimeout(() => {
Spotlight.focus(currentSpot);
});
}
},
[dispatch]
);
//첫번째 옵션 선택 함수
const handleOptionClick = useCallback(
(optionValIdx) => {
@@ -302,6 +322,7 @@ export default function SingleOption({
return;
}
if (webOSVersion >= "6.0") {
Spotlight.focus();
dispatch(setHidePopup());
@@ -442,16 +463,6 @@ export default function SingleOption({
}
}, [dispatch, selectedCoupon, userNumber, couponCodes]);
const onClose = useCallback(
(spotlightId) => {
dispatch(setHidePopup());
setTimeout(() => {
Spotlight.focus(spotlightId ? spotlightId : "spotlightId_buynowBtn");
});
},
[dispatch]
);
useEffect(() => {
if (selectedCoupon) {
getCouponCode();