[251019] fix: YouMayAlsoLike.jsx pushPanel->updatePanel

🕐 커밋 시간: 2025. 10. 19. 18:02:54

📊 변경 통계:
  • 총 파일: 1개
  • 추가: +10줄
  • 삭제: -2줄

📝 수정된 파일:
  ~ com.twin.app.shoptime/src/views/DetailPanel/ProductContentSection/YouMayAlsoLike/YouMayAlsoLike.jsx
This commit is contained in:
2025-10-19 18:02:58 +09:00
parent 231cbe163a
commit 500bf50d5a

View File

@@ -1,52 +1,33 @@
import React, { import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import { import { useDispatch, useSelector } from 'react-redux';
useDispatch,
useSelector,
} from 'react-redux';
import { Job } from '@enact/core/util'; import { Job } from '@enact/core/util';
import SpotlightContainerDecorator import SpotlightContainerDecorator from '@enact/spotlight/SpotlightContainerDecorator';
from '@enact/spotlight/SpotlightContainerDecorator';
import Spottable from '@enact/spotlight/Spottable'; import Spottable from '@enact/spotlight/Spottable';
import { clearThemeDetail } from '../../../../actions/homeActions'; import { clearThemeDetail } from '../../../../actions/homeActions';
import { import { popPanel, pushPanel, updatePanel } from '../../../../actions/panelActions';
popPanel,
pushPanel,
} from '../../../../actions/panelActions';
import { finishVideoPreview } from '../../../../actions/playActions'; import { finishVideoPreview } from '../../../../actions/playActions';
import THeader from '../../../../components/THeader/THeader'; import THeader from '../../../../components/THeader/THeader';
import TItemCard from '../../../../components/TItemCard/TItemCard'; import TItemCard from '../../../../components/TItemCard/TItemCard';
import TVerticalPagenator import TVerticalPagenator from '../../../../components/TVerticalPagenator/TVerticalPagenator';
from '../../../../components/TVerticalPagenator/TVerticalPagenator'; import TVirtualGridList from '../../../../components/TVirtualGridList/TVirtualGridList';
import TVirtualGridList
from '../../../../components/TVirtualGridList/TVirtualGridList';
import useScrollTo from '../../../../hooks/useScrollTo'; import useScrollTo from '../../../../hooks/useScrollTo';
import { import { LOG_CONTEXT_NAME, LOG_MESSAGE_ID, panel_names } from '../../../../utils/Config';
LOG_CONTEXT_NAME,
LOG_MESSAGE_ID,
panel_names,
} from '../../../../utils/Config';
import { $L } from '../../../../utils/helperMethods'; import { $L } from '../../../../utils/helperMethods';
import css from './YouMayAlsoLike.module.less'; import css from './YouMayAlsoLike.module.less';
const SpottableComponent = Spottable("div"); const SpottableComponent = Spottable('div');
const Container = SpotlightContainerDecorator( const Container = SpotlightContainerDecorator(
{ {
enterTo: "last-focused", enterTo: 'last-focused',
leaveFor: { leaveFor: {
left: "spotlight-product-info-section-container", left: 'spotlight-product-info-section-container',
}, },
}, },
"div" 'div'
); );
export default function YouMayAlsoLike({ export default function YouMayAlsoLike({
@@ -79,10 +60,7 @@ export default function YouMayAlsoLike({
youmaylikeProductData.length > 0 && youmaylikeProductData.length > 0 &&
youmaylikeProductData.length > 9 youmaylikeProductData.length > 9
) { ) {
const processedData = youmaylikeProductData.slice( const processedData = youmaylikeProductData.slice(0, youmaylikeProductData.length - 1);
0,
youmaylikeProductData.length - 1
);
// console.log('[YouMayLike] 처리된 데이터 설정:', { // console.log('[YouMayLike] 처리된 데이터 설정:', {
// processedLength: processedData.length, // processedLength: processedData.length,
// processedData // processedData
@@ -95,21 +73,15 @@ export default function YouMayAlsoLike({
}, [youmaylikeProductData]); }, [youmaylikeProductData]);
const panels = useSelector((state) => state.panels.panels); const panels = useSelector((state) => state.panels.panels);
const themeProductInfos = useSelector( const themeProductInfos = useSelector((state) => state.home.themeCurationDetailInfoData);
(state) => state.home.themeCurationDetailInfoData
);
// const [focused, setFocused] = useState(false); // const [focused, setFocused] = useState(false);
const cursorOpen = useRef(new Job((func) => func(), 1000)); const cursorOpen = useRef(new Job((func) => func(), 1000));
const launchedFromPlayer = useMemo(() => { const launchedFromPlayer = useMemo(() => {
const detailPanelIndex = panels.findIndex( const detailPanelIndex = panels.findIndex(({ name }) => name === 'detailpanel');
({ name }) => name === "detailpanel" const playerPanelIndex = panels.findIndex(({ name }) => name === 'playerpanel');
);
const playerPanelIndex = panels.findIndex(
({ name }) => name === "playerpanel"
);
return detailPanelIndex - 1 === playerPanelIndex; return detailPanelIndex - 1 === playerPanelIndex;
}, [panels]); }, [panels]);
@@ -142,19 +114,15 @@ export default function YouMayAlsoLike({
<div> <div>
{newYoumaylikeProductData && newYoumaylikeProductData.length > 0 && ( {newYoumaylikeProductData && newYoumaylikeProductData.length > 0 && (
<TVerticalPagenator <TVerticalPagenator
spotlightId={"detail_youMayAlsoLike_area"} spotlightId={'detail_youMayAlsoLike_area'}
data-wheel-point={true} data-wheel-point={true}
className={css.tVerticalPagenator} className={css.tVerticalPagenator}
defaultContainerId={panelInfo?.focusedContainerId} defaultContainerId={panelInfo?.focusedContainerId}
onFocusedContainerId={onFocusedContainerId} onFocusedContainerId={onFocusedContainerId}
topMargin={36} topMargin={36}
> >
<Container <Container className={css.container} onFocus={_onFocus} onBlur={_onBlur}>
className={css.container} <THeader title={$L('YOU MAY ALSO LIKE')} className={css.tHeader} />
onFocus={_onFocus}
onBlur={_onBlur}
>
<THeader title={$L("YOU MAY ALSO LIKE")} className={css.tHeader} />
<div className={css.renderCardContainer}> <div className={css.renderCardContainer}>
{newYoumaylikeProductData?.map((product, index) => { {newYoumaylikeProductData?.map((product, index) => {
const { const {
@@ -171,15 +139,22 @@ export default function YouMayAlsoLike({
const handleItemClick = () => { const handleItemClick = () => {
dispatch(finishVideoPreview()); dispatch(finishVideoPreview());
dispatch(popPanel(panel_names.DETAIL_PANEL));
if (themeProductInfos && themeProductInfos.length > 0) { if (themeProductInfos && themeProductInfos.length > 0) {
dispatch(clearThemeDetail()); dispatch(clearThemeDetail());
} }
// popPanel + pushPanel 대신 updatePanel 사용
// DetailPanel을 언마운트하지 않고 상품 정보만 업데이트
// 이렇게 하면 백그라운드 비디오 제어 상태가 유지됨
dispatch( dispatch(
pushPanel({ updatePanel({
name: panel_names.DETAIL_PANEL, name: panel_names.DETAIL_PANEL,
panelInfo: { panelInfo: {
showNm: panelInfo?.showNm,
showId: panelInfo?.showId,
liveFlag: panelInfo?.liveFlag,
thumbnailUrl: panelInfo?.thumbnailUrl,
patnrId, patnrId,
prdtId, prdtId,
launchedFromPlayer: launchedFromPlayer, launchedFromPlayer: launchedFromPlayer,
@@ -207,9 +182,7 @@ export default function YouMayAlsoLike({
offerInfo={offerInfo} offerInfo={offerInfo}
productName={prdtNm} productName={prdtNm}
onClick={handleItemClick} onClick={handleItemClick}
label={ label={index * 1 + 1 + ' of ' + newYoumaylikeProductData.length}
index * 1 + 1 + " of " + newYoumaylikeProductData.length
}
lastLabel=" go to detail, button" lastLabel=" go to detail, button"
/> />
); );