diff --git a/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNav.jsx b/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNav.jsx index da525c5d..eb9d5bf0 100644 --- a/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNav.jsx +++ b/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNav.jsx @@ -1,9 +1,10 @@ import React, { useCallback } from "react"; import { VirtualGridList } from "@enact/sandstone/VirtualList"; -import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator"; +import { setContainerLastFocusedElement } from "@enact/spotlight/src/container"; import { scaleH, scaleW } from "../../../utils/helperMethods"; +import { SpotlightIds } from "../../../utils/SpotlightIds"; import CategoryNavItem from "../CategoryNav/CategoryNavItem/CategoryNavItem"; import css from "./CategoryNav.module.less"; @@ -13,11 +14,6 @@ const LIST_ITEM_CONF = { SAPCING: 30, }; -const Container = SpotlightContainerDecorator( - { leaveFor: { right: "" } }, - "nav" -); - export default function CategoryNav({ categoryInfos, currentCategoryCode, @@ -28,9 +24,10 @@ export default function CategoryNav({ const handleCategoryNavClick = useCallback( (categoryCode) => { if (currentCategoryCode === categoryCode) { - return; + return scrollTop(); } + setContainerLastFocusedElement(null, [`${SpotlightIds.TBODY}`]); setCurrentCategoryCode(categoryCode); scrollTop(); }, @@ -53,7 +50,7 @@ export default function CategoryNav({ ); return ( - + ); } diff --git a/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNavItem/CategoryNavItem.jsx b/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNavItem/CategoryNavItem.jsx index a3884cd2..ba985b8e 100644 --- a/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNavItem/CategoryNavItem.jsx +++ b/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNavItem/CategoryNavItem.jsx @@ -33,8 +33,9 @@ export default memo(function CategoryNavItem({ css.category, categoryCode === currentCategoryCode && css.selected )} - key={categoryCode} + key={"categoryInfo-" + index} onClick={() => handleClick(categoryCode)} + spotlightId={"spotlightId-" + currentCategoryCode} {...rest} >
diff --git a/com.twin.app.shoptime/src/views/OnSalePanel/OnSalePanel.jsx b/com.twin.app.shoptime/src/views/OnSalePanel/OnSalePanel.jsx index 7ea5f08d..f0231629 100644 --- a/com.twin.app.shoptime/src/views/OnSalePanel/OnSalePanel.jsx +++ b/com.twin.app.shoptime/src/views/OnSalePanel/OnSalePanel.jsx @@ -2,12 +2,14 @@ import React, { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; +import Spotlight from "@enact/spotlight"; + import { getOnSaleInfo } from "../../actions/onSaleActions"; import TBody from "../../components/TBody/TBody"; +import { removeDotAndColon } from "../../components/TItemCard/TItemCard"; import TopButton from "../../components/TopButton/TopButton"; import TPanel from "../../components/TPanel/TPanel"; import useScrollTo from "../../hooks/useScrollTo"; -import { SpotlightIds } from "../../utils/SpotlightIds"; import CategoryNav from "../OnSalePanel/CategoryNav/CategoryNav"; import css from "./OnSalePanel.module.less"; import OnSaleProductList from "./OnSaleProductList/OnSaleProductList"; @@ -23,12 +25,12 @@ export default function OnSalePanel() { const saleInfos = useSelector((state) => state.onSale.onSaleData.saleInfos); const [currentCategoryCode, setCurrentCategoryCode] = useState(); + const [initialLoad, setInitialLoad] = useState(true); const [targetId, setTargetId] = useState(); useEffect(() => { if (categoryInfos && !currentCategoryCode) { - const initialLgCatCd = categoryInfos[0].lgCatCd; - setCurrentCategoryCode(initialLgCatCd); + setCurrentCategoryCode(categoryInfos[0].lgCatCd); } }, []); @@ -42,11 +44,18 @@ export default function OnSalePanel() { useEffect(() => { if (saleInfos) { - const id = saleInfos[0].saleProductInfos[0].prdtId; - setTargetId(SpotlightIds.TITEM_CARD + id); + const productId = saleInfos[0].saleProductInfos[0].prdtId; + setTargetId("spotlightId-" + removeDotAndColon(productId)); } }, [dispatch, saleInfos]); + useEffect(() => { + if (currentCategoryCode && initialLoad) { + Spotlight.focus("spotlightId-" + currentCategoryCode); + setInitialLoad(false); + } + }, [currentCategoryCode, initialLoad]); + return ( {saleInfos && - saleInfos.map(({ saleNm, saleProductInfos }) => ( + saleInfos.map(({ saleNm, saleProductInfos }, index) => ( diff --git a/com.twin.app.shoptime/src/views/OnSalePanel/OnSaleProductList/OnSaleProductList.jsx b/com.twin.app.shoptime/src/views/OnSalePanel/OnSaleProductList/OnSaleProductList.jsx index 9739f625..4110c3f2 100644 --- a/com.twin.app.shoptime/src/views/OnSalePanel/OnSaleProductList/OnSaleProductList.jsx +++ b/com.twin.app.shoptime/src/views/OnSalePanel/OnSaleProductList/OnSaleProductList.jsx @@ -1,7 +1,6 @@ import React, { useCallback } from "react"; import { VirtualGridList } from "@enact/sandstone/VirtualList"; -import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator"; import SectionTitle from "../../../components/SectionTitle/SectionTitle"; import { scaleH, scaleW } from "../../../utils/helperMethods"; @@ -14,11 +13,6 @@ const LIST_ITEM_CONF = { SAPCING: 18, }; -const Container = SpotlightContainerDecorator( - { leaveFor: { right: "" } }, - "div" -); - export default function OnSaleProductList({ saleName, saleProductInfos, @@ -38,7 +32,7 @@ export default function OnSaleProductList({ ); return ( - +
{saleName && } {saleProductInfos && ( @@ -57,6 +51,6 @@ export default function OnSaleProductList({ spacing={scaleW(LIST_ITEM_CONF.SAPCING)} /> )} - +
); }