[251025] fix: SearchPanel.new.v2 Focus복원 1회성 처리
🕐 커밋 시간: 2025. 10. 25. 23:01:28 📊 변경 통계: • 총 파일: 1개 • 추가: +33줄 • 삭제: -8줄 📝 수정된 파일: ~ com.twin.app.shoptime/src/views/SearchPanel/SearchPanel.new.v2.jsx 🔧 주요 변경 내용: • 소규모 기능 개선
This commit is contained in:
@@ -259,6 +259,7 @@ export default function SearchPanel({ panelInfo, isOnTop, spotlightId }) {
|
||||
const isSearchOverlayVisibleRef = useRef(false);
|
||||
const currentModeRef = useRef(SEARCH_PANEL_MODES.INITIAL);
|
||||
const unifiedFocusTimerRef = useRef(null);
|
||||
const detailReturnHandledRef = useRef(false);
|
||||
|
||||
// Spottable 컴포넌트 캐싱으로 메모리 누수 방지
|
||||
const SpottableMicButton = useMemo(() => Spottable('div'), []);
|
||||
@@ -1444,9 +1445,29 @@ export default function SearchPanel({ panelInfo, isOnTop, spotlightId }) {
|
||||
});
|
||||
}
|
||||
|
||||
const scenario = analyzeCurrentScenario();
|
||||
const isDetailReturnScenario = scenario === 'DETAIL_PANEL_RETURN';
|
||||
|
||||
// DETAIL_PANEL_RETURN 시나리오가 아니면 다음 복귀를 위해 플래그 초기화
|
||||
if (!isDetailReturnScenario && detailReturnHandledRef.current) {
|
||||
detailReturnHandledRef.current = false;
|
||||
}
|
||||
|
||||
// DETAIL_PANEL_RETURN이 반복 감지되었지만 이미 처리한 경우에는 조기 종료
|
||||
if (isDetailReturnScenario && detailReturnHandledRef.current) {
|
||||
shopperHouseDataRef.current = shopperHouseData;
|
||||
isVoiceOverlayVisibleRef.current = isVoiceOverlayVisible;
|
||||
isSearchOverlayVisibleRef.current = isSearchOverlayVisible;
|
||||
currentModeRef.current = currentMode;
|
||||
return;
|
||||
}
|
||||
|
||||
// 포커스 타겟 결정
|
||||
const targetId = determineFocusTarget();
|
||||
const scenario = analyzeCurrentScenario();
|
||||
// DETAIL_PANEL_RETURN 처리 시작 시점에 일회성 플래그 설정
|
||||
if (isDetailReturnScenario && !detailReturnHandledRef.current) {
|
||||
detailReturnHandledRef.current = true;
|
||||
}
|
||||
|
||||
// 변화 없으면 포커스 이동하지 않음
|
||||
if (!targetId) {
|
||||
@@ -1481,19 +1502,23 @@ export default function SearchPanel({ panelInfo, isOnTop, spotlightId }) {
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
} else if (DEBUG_MODE) {
|
||||
console.log('[FOCUS] ⚠️ 포커스 대상 요소를 찾지 못했습니다:', {
|
||||
targetId,
|
||||
scenario,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
} else {
|
||||
if (DEBUG_MODE) {
|
||||
console.log('[FOCUS] ⚠️ 포커스 대상 요소를 찾지 못했습니다:', {
|
||||
targetId,
|
||||
scenario,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
|
||||
// 🎯 DETAIL_PANEL_RETURN에서 요소를 찾지 못하면 fallback으로 첫 번째 상품 시도
|
||||
if (scenario === 'DETAIL_PANEL_RETURN' && targetId.startsWith('searchItemContents')) {
|
||||
const fallbackTarget = 'searchItemContents0';
|
||||
const fallbackElement = document.querySelector(`[data-spotlight-id="${fallbackTarget}"]`);
|
||||
if (fallbackElement) {
|
||||
console.log('[FOCUS] 🔄 DETAIL_PANEL_RETURN fallback: 첫 번째 상품으로 포커스:', fallbackTarget);
|
||||
if (DEBUG_MODE) {
|
||||
console.log('[FOCUS] 🔄 DETAIL_PANEL_RETURN fallback: 첫 번째 상품으로 포커스:', fallbackTarget);
|
||||
}
|
||||
Spotlight.focus(fallbackTarget);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user