[components] modify for 2depth subItem in TabLayout.jsx and TabItemSub.jsx
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user