[OnSalePanel] 버그 수정, 불필요 lib 삭제
Detail Notes : 1. 초기 진입시 focus 문제 수정 2. 마우스로 nav 클릭 후 최상단에서 키보드로 포커스 이동 시 이전 포커스로 이동하는 문제 수정 3. 불필요 SpotlightContainerDecorator 삭제 4. 일부 SpottableComponent, spotlightId 수정
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
|
|
||||||
import { VirtualGridList } from "@enact/sandstone/VirtualList";
|
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 { scaleH, scaleW } from "../../../utils/helperMethods";
|
||||||
|
import { SpotlightIds } from "../../../utils/SpotlightIds";
|
||||||
import CategoryNavItem from "../CategoryNav/CategoryNavItem/CategoryNavItem";
|
import CategoryNavItem from "../CategoryNav/CategoryNavItem/CategoryNavItem";
|
||||||
import css from "./CategoryNav.module.less";
|
import css from "./CategoryNav.module.less";
|
||||||
|
|
||||||
@@ -13,11 +14,6 @@ const LIST_ITEM_CONF = {
|
|||||||
SAPCING: 30,
|
SAPCING: 30,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Container = SpotlightContainerDecorator(
|
|
||||||
{ leaveFor: { right: "" } },
|
|
||||||
"nav"
|
|
||||||
);
|
|
||||||
|
|
||||||
export default function CategoryNav({
|
export default function CategoryNav({
|
||||||
categoryInfos,
|
categoryInfos,
|
||||||
currentCategoryCode,
|
currentCategoryCode,
|
||||||
@@ -28,9 +24,10 @@ export default function CategoryNav({
|
|||||||
const handleCategoryNavClick = useCallback(
|
const handleCategoryNavClick = useCallback(
|
||||||
(categoryCode) => {
|
(categoryCode) => {
|
||||||
if (currentCategoryCode === categoryCode) {
|
if (currentCategoryCode === categoryCode) {
|
||||||
return;
|
return scrollTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setContainerLastFocusedElement(null, [`${SpotlightIds.TBODY}`]);
|
||||||
setCurrentCategoryCode(categoryCode);
|
setCurrentCategoryCode(categoryCode);
|
||||||
scrollTop();
|
scrollTop();
|
||||||
},
|
},
|
||||||
@@ -53,7 +50,7 @@ export default function CategoryNav({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className={css.container} {...rest}>
|
<nav className={css.container} {...rest}>
|
||||||
{categoryInfos && categoryInfos.length > 0 && (
|
{categoryInfos && categoryInfos.length > 0 && (
|
||||||
<VirtualGridList
|
<VirtualGridList
|
||||||
className={css.virtualGridList}
|
className={css.virtualGridList}
|
||||||
@@ -70,6 +67,6 @@ export default function CategoryNav({
|
|||||||
spacing={scaleW(LIST_ITEM_CONF.SAPCING)}
|
spacing={scaleW(LIST_ITEM_CONF.SAPCING)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Container>
|
</nav>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ export default memo(function CategoryNavItem({
|
|||||||
css.category,
|
css.category,
|
||||||
categoryCode === currentCategoryCode && css.selected
|
categoryCode === currentCategoryCode && css.selected
|
||||||
)}
|
)}
|
||||||
key={categoryCode}
|
key={"categoryInfo-" + index}
|
||||||
onClick={() => handleClick(categoryCode)}
|
onClick={() => handleClick(categoryCode)}
|
||||||
|
spotlightId={"spotlightId-" + currentCategoryCode}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ import React, { useEffect, useState } from "react";
|
|||||||
|
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
|
import Spotlight from "@enact/spotlight";
|
||||||
|
|
||||||
import { getOnSaleInfo } from "../../actions/onSaleActions";
|
import { getOnSaleInfo } from "../../actions/onSaleActions";
|
||||||
import TBody from "../../components/TBody/TBody";
|
import TBody from "../../components/TBody/TBody";
|
||||||
|
import { removeDotAndColon } from "../../components/TItemCard/TItemCard";
|
||||||
import TopButton from "../../components/TopButton/TopButton";
|
import TopButton from "../../components/TopButton/TopButton";
|
||||||
import TPanel from "../../components/TPanel/TPanel";
|
import TPanel from "../../components/TPanel/TPanel";
|
||||||
import useScrollTo from "../../hooks/useScrollTo";
|
import useScrollTo from "../../hooks/useScrollTo";
|
||||||
import { SpotlightIds } from "../../utils/SpotlightIds";
|
|
||||||
import CategoryNav from "../OnSalePanel/CategoryNav/CategoryNav";
|
import CategoryNav from "../OnSalePanel/CategoryNav/CategoryNav";
|
||||||
import css from "./OnSalePanel.module.less";
|
import css from "./OnSalePanel.module.less";
|
||||||
import OnSaleProductList from "./OnSaleProductList/OnSaleProductList";
|
import OnSaleProductList from "./OnSaleProductList/OnSaleProductList";
|
||||||
@@ -23,12 +25,12 @@ export default function OnSalePanel() {
|
|||||||
const saleInfos = useSelector((state) => state.onSale.onSaleData.saleInfos);
|
const saleInfos = useSelector((state) => state.onSale.onSaleData.saleInfos);
|
||||||
|
|
||||||
const [currentCategoryCode, setCurrentCategoryCode] = useState();
|
const [currentCategoryCode, setCurrentCategoryCode] = useState();
|
||||||
|
const [initialLoad, setInitialLoad] = useState(true);
|
||||||
const [targetId, setTargetId] = useState();
|
const [targetId, setTargetId] = useState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (categoryInfos && !currentCategoryCode) {
|
if (categoryInfos && !currentCategoryCode) {
|
||||||
const initialLgCatCd = categoryInfos[0].lgCatCd;
|
setCurrentCategoryCode(categoryInfos[0].lgCatCd);
|
||||||
setCurrentCategoryCode(initialLgCatCd);
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -42,11 +44,18 @@ export default function OnSalePanel() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (saleInfos) {
|
if (saleInfos) {
|
||||||
const id = saleInfos[0].saleProductInfos[0].prdtId;
|
const productId = saleInfos[0].saleProductInfos[0].prdtId;
|
||||||
setTargetId(SpotlightIds.TITEM_CARD + id);
|
setTargetId("spotlightId-" + removeDotAndColon(productId));
|
||||||
}
|
}
|
||||||
}, [dispatch, saleInfos]);
|
}, [dispatch, saleInfos]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (currentCategoryCode && initialLoad) {
|
||||||
|
Spotlight.focus("spotlightId-" + currentCategoryCode);
|
||||||
|
setInitialLoad(false);
|
||||||
|
}
|
||||||
|
}, [currentCategoryCode, initialLoad]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TPanel className={css.container}>
|
<TPanel className={css.container}>
|
||||||
<CategoryNav
|
<CategoryNav
|
||||||
@@ -57,9 +66,9 @@ export default function OnSalePanel() {
|
|||||||
/>
|
/>
|
||||||
<TBody className={css.tBody} cbScrollTo={getScrollTo}>
|
<TBody className={css.tBody} cbScrollTo={getScrollTo}>
|
||||||
{saleInfos &&
|
{saleInfos &&
|
||||||
saleInfos.map(({ saleNm, saleProductInfos }) => (
|
saleInfos.map(({ saleNm, saleProductInfos }, index) => (
|
||||||
<OnSaleProductList
|
<OnSaleProductList
|
||||||
key={saleNm}
|
key={"saleInfo-" + index}
|
||||||
saleName={saleNm}
|
saleName={saleNm}
|
||||||
saleProductInfos={saleProductInfos}
|
saleProductInfos={saleProductInfos}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
|
|
||||||
import { VirtualGridList } from "@enact/sandstone/VirtualList";
|
import { VirtualGridList } from "@enact/sandstone/VirtualList";
|
||||||
import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator";
|
|
||||||
|
|
||||||
import SectionTitle from "../../../components/SectionTitle/SectionTitle";
|
import SectionTitle from "../../../components/SectionTitle/SectionTitle";
|
||||||
import { scaleH, scaleW } from "../../../utils/helperMethods";
|
import { scaleH, scaleW } from "../../../utils/helperMethods";
|
||||||
@@ -14,11 +13,6 @@ const LIST_ITEM_CONF = {
|
|||||||
SAPCING: 18,
|
SAPCING: 18,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Container = SpotlightContainerDecorator(
|
|
||||||
{ leaveFor: { right: "" } },
|
|
||||||
"div"
|
|
||||||
);
|
|
||||||
|
|
||||||
export default function OnSaleProductList({
|
export default function OnSaleProductList({
|
||||||
saleName,
|
saleName,
|
||||||
saleProductInfos,
|
saleProductInfos,
|
||||||
@@ -38,7 +32,7 @@ export default function OnSaleProductList({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className={css.container} {...rest}>
|
<div className={css.container} {...rest}>
|
||||||
{saleName && <SectionTitle title={saleName} />}
|
{saleName && <SectionTitle title={saleName} />}
|
||||||
|
|
||||||
{saleProductInfos && (
|
{saleProductInfos && (
|
||||||
@@ -57,6 +51,6 @@ export default function OnSaleProductList({
|
|||||||
spacing={scaleW(LIST_ITEM_CONF.SAPCING)}
|
spacing={scaleW(LIST_ITEM_CONF.SAPCING)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Container>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user