[components] modify for 2depth subItem in TabLayout.jsx and TabItemSub.jsx

This commit is contained in:
younghoon100.park
2024-07-11 18:26:22 +09:00
parent dafdeeca9a
commit 0df7adea47
2 changed files with 41 additions and 54 deletions

View File

@@ -10,6 +10,7 @@ import Spottable from "@enact/spotlight/Spottable";
import css from "./TabItemSub.module.less";
const SpottableComponent = Spottable("div");
const TabItemBase = ({
selected = false,
expanded = false,
@@ -31,60 +32,41 @@ const TabItemBase = ({
...rest
}) => {
const [focused, setFocused] = useState(false);
const itemRef = useRef();
const clearPressedJob = useRef(
new Job((func) => {
setTimeout(func, 0);
}, 0)
);
const _onClick = useCallback(
(ev) => {
clearPressedJob.current.start(() => {
if (itemId) {
setSelectedSubItemId(itemId);
}
if (spotlightId) {
setLastFocusId(spotlightId);
}
if (onClick) {
onClick({
// index,
target,
// title,
// path,
itemId,
});
// if (path) {
// setSelectedTitle(path);
// } else {
// setSelectedTitle(title);
// }
if (itemId) {
setSelectedSubItemId(itemId);
}
if (spotlightId) {
setLastFocusId(spotlightId);
}
onClick({ target, itemId });
}
});
},
[
// index,
// title,
// path,
target,
itemId,
onClick,
spotlightId,
setSelectedSubItemId,
setLastFocusId,
]
[target, itemId, onClick, spotlightId, setSelectedSubItemId, setLastFocusId]
);
const _onFocus = useCallback(() => {
setFocused(true);
setSelectedSubItemId(null);
if (onFocus) {
onFocus(index);
}
}, [index, onFocus, setSelectedSubItemId]);
}, [index, onFocus]);
const _onBlur = useCallback(() => {
setFocused(false);