diff --git a/com.twin.app.shoptime/src/views/MyPagePanel/MyPageSub/RecentlyViewed/RecentlyViewed.jsx b/com.twin.app.shoptime/src/views/MyPagePanel/MyPageSub/RecentlyViewed/RecentlyViewed.jsx index 9452ffed..051c0825 100644 --- a/com.twin.app.shoptime/src/views/MyPagePanel/MyPageSub/RecentlyViewed/RecentlyViewed.jsx +++ b/com.twin.app.shoptime/src/views/MyPagePanel/MyPageSub/RecentlyViewed/RecentlyViewed.jsx @@ -61,17 +61,24 @@ export default function RecentlyViewed({ title, panelInfo, isOnTop }) { useEffect(() => { if (recentlyDatas) { setTimeout(() => { - const node = document.querySelector(`[id="${SpotlightIds.TBODY}"]`); - if (activeDelete) { - Spotlight.focus("recentlyviewed_header"); - } else if (recentlyDatas.length === 0) { - Spotlight.focus("mypage-recentlyViewed-nodata"); - } else if (node) { - Spotlight.focus(node); + const tHeader = document.querySelector( + `[data-spotlight-id="recentlyviewed_header"]` + ); + const tBody = document.querySelector(`[id="${SpotlightIds.TBODY}"]`); + + if (isOnTop) { + if (cbChangePageRef.current) { + cbChangePageRef.current(0, false); + + if (tHeader && tBody) { + const focusTarget = activeDelete ? tHeader : tBody; + Spotlight.focus(focusTarget); + } + } } - }, 0); + }); } - }, [recentlyDatas]); + }, [isOnTop, recentlyDatas]); useEffect(() => { if (panelInfo) {