[No Jira Issue] IF-LGSP-LOG-005 (GNB 이력) Magic Mouse 대응 (TrendingNowPanel 3차)
Changed files: 1. TrendingNowPanel.jsx Detail Note: 1. add logic for focus recovery
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import React, { useCallback, useEffect, useRef } from "react";
|
||||
|
||||
import classNames from "classnames";
|
||||
import { useDispatch } from "react-redux";
|
||||
@@ -64,37 +64,48 @@ const TrendingNowPanel = ({ panelInfo, spotlightId, isOnTop, ...rest }) => {
|
||||
const isInitialRef = useRef(true);
|
||||
const focusedContainerIdRef = useRef(panelInfo?.focusedContainerId);
|
||||
|
||||
// effect: data fetching when no data exists in the store
|
||||
useEffect(() => {
|
||||
if (!topInfos) dispatch(getTop20Show());
|
||||
if (!bestSeller) dispatch(getBestSeller());
|
||||
}, [dispatch]);
|
||||
}, []);
|
||||
|
||||
// effect: focus handling on initial render
|
||||
useEffect(() => {
|
||||
if (isInitialRef.current && !panelInfo?.currentSpot) {
|
||||
if (topInfos && bestSeller) {
|
||||
const target =
|
||||
panelInfo?.pageName === "BS"
|
||||
? SpotlightIds.TRENDING_NOW_BEST_SELLER
|
||||
: SpotlightIds.TRENDING_NOW_POPULAR_SHOW;
|
||||
let target;
|
||||
switch (panelInfo?.pageName) {
|
||||
case "PS":
|
||||
target = SpotlightIds.TRENDING_NOW_POPULAR_SHOW;
|
||||
break;
|
||||
case "BS":
|
||||
target = SpotlightIds.TRENDING_NOW_BEST_SELLER;
|
||||
break;
|
||||
}
|
||||
|
||||
Spotlight.focus(target);
|
||||
if (target) Spotlight.focus(target);
|
||||
isInitialRef.current = false;
|
||||
}
|
||||
}
|
||||
}, [topInfos, bestSeller]);
|
||||
|
||||
useEffect(() => {
|
||||
if (panelInfo?.currentSpot) Spotlight.focus(panelInfo.currentSpot);
|
||||
}, [panelInfo?.currentSpot]);
|
||||
|
||||
// effect: set the index when returning to the details or entering through a deep-link
|
||||
useEffect(() => {
|
||||
if (panelInfo?.selectedIndex) setSelectedIndex(panelInfo.selectedIndex);
|
||||
}, [panelInfo?.selectedIndex]);
|
||||
}, []);
|
||||
|
||||
// effect: focus recovery when returning to the details
|
||||
useEffect(() => {
|
||||
if (isOnTop && panelInfo?.currentSpot) {
|
||||
Spotlight.focus(panelInfo.currentSpot);
|
||||
}
|
||||
}, [isOnTop]);
|
||||
|
||||
// effect: for the GNB log
|
||||
useEffect(() => {
|
||||
if (isOnTop) {
|
||||
let menu;
|
||||
|
||||
// case: entering through a deep link or the Home, and returning from the player or details
|
||||
if (panelInfo?.focusedContainerId) {
|
||||
menu =
|
||||
|
||||
Reference in New Issue
Block a user