Skip to content

Commit 3f94201

Browse files
committed
Fixed issue with XmbContext
1 parent c16d432 commit 3f94201

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎src/context/XmbContext.tsx‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export function XmbProvider({ children }: { children: React.ReactNode }) {
8888
setCurrentItem(cat.items[0]);
8989

9090
// save the item ref to find items by key directly
91-
for (let i = 0; i < menu.items.length - 1; i++) {
91+
for (let i = 0; i < menu.items.length; i++) {
9292
const cat = menu.items[i];
93-
for (let j = 0; j < cat.items.length - 1; j++) {
93+
for (let j = 0; j < cat.items.length; j++) {
9494
const item = cat.items[j];
9595
xmbItemRef.current.set(toXmbKey(i, j), item);
9696
}
@@ -140,12 +140,17 @@ export function XmbProvider({ children }: { children: React.ReactNode }) {
140140
}, []);
141141

142142
const onEnter = useCallback(() => {
143-
if (!currentItem) return;
143+
if (!xmbItemRef.current) return;
144144

145145
play(XMB_AUDIO_SRC);
146146

147-
openItem(currentItem);
148-
}, [modal, currentItem]);
147+
const key = toXmbKey(x, y);
148+
const item = xmbItemRef.current.get(key);
149+
150+
if (!item) return;
151+
152+
openItem(item);
153+
}, [x, y]);
149154

150155
const moveDefault = useCallback(() => {
151156
updateX(0, false);

0 commit comments

Comments
 (0)