TermsOfService - delete setTimeout and changed logic for focus

This commit is contained in:
hyunwoo93.cha
2024-06-10 21:34:14 +09:00
parent f95ba1c138
commit ae1b35d323

View File

@@ -35,6 +35,7 @@ export default function TermsOfService({ title, cbScrollTo }) {
const webOSVersion = useSelector(
(state) => state.common.appStatus.webOSVersion
);
const [spotlightDisabled, setSpotlightDisabled] = useState(true);
const [termsList, setTermsList] = useState([]);
const dispatch = useDispatch();
@@ -72,9 +73,7 @@ export default function TermsOfService({ title, cbScrollTo }) {
setTermsList(tempList);
setTrmsCdList(newTrmsCdList);
setTimeout(() => {
Spotlight.focus("tab-0");
}, 50);
setSpotlightDisabled(false);
}, [termsData, empTermsData, webOSVersion]);
const handleItemClick = useCallback(
@@ -82,15 +81,22 @@ export default function TermsOfService({ title, cbScrollTo }) {
setSelectedTab(index);
setResetScroll(true);
setTimeout(() => {
setResetScroll(false);
}, 50);
},
[trmsTpCd]
);
useEffect(() => {
if (!spotlightDisabled) {
Spotlight.focus("tab-0");
}
}, [spotlightDisabled]);
useEffect(() => {
if (resetScroll) {
setResetScroll(false);
}
}, [resetScroll]);
const handleDisagree = useCallback(() => {
dispatch(setShowPopup(Config.ACTIVE_POPUP.exitPopup));
}, [dispatch]);
@@ -139,6 +145,7 @@ export default function TermsOfService({ title, cbScrollTo }) {
boxHeight={scaleH(714)}
width={scaleW(1680)}
resetScrollPosition={resetScroll}
forcedFocus={false}
>
<div
className={css.textBox}
@@ -171,6 +178,7 @@ export default function TermsOfService({ title, cbScrollTo }) {
<div className={css.buttonBox}>
<TButton
spotlightDisabled={spotlightDisabled}
onClick={
termsList[selectedTab]?.termsId === "TID0000222" ||
termsList[selectedTab]?.termsId === "TID0000223"