feat: allow clicking keyboard hints throughout (#266)
* allow clicking keyboard hints * Update js/desktop/src/components/key-hint.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * nits --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit was merged in pull request #266.
This commit is contained in:
co-authored by
coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
parent
9fd7e611f3
commit
95f2362947
@@ -1,5 +1,4 @@
|
||||
import { useEffect, type RefObject } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import type { MediaParticleHandle } from '@/features/particles/media-particle-view';
|
||||
import { isTypingTarget } from '@/lib/keyboard';
|
||||
|
||||
@@ -11,6 +10,7 @@ interface UseStreamNavigationKeysOptions {
|
||||
currentIndex: number;
|
||||
childrenLength: number;
|
||||
mediaRef: RefObject<MediaParticleHandle | null>;
|
||||
onExit: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,9 +23,8 @@ export function useStreamNavigationKeys({
|
||||
currentIndex,
|
||||
childrenLength,
|
||||
mediaRef,
|
||||
onExit,
|
||||
}: UseStreamNavigationKeysOptions) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (isTypingTarget(e)) return;
|
||||
@@ -53,12 +52,12 @@ export function useStreamNavigationKeys({
|
||||
break;
|
||||
case 'Escape':
|
||||
e.preventDefault();
|
||||
navigate(-1);
|
||||
onExit();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
return () => window.removeEventListener('keydown', onKeyDown);
|
||||
}, [next, prev, currentIndex, childrenLength, mediaRef, navigate]);
|
||||
}, [next, prev, currentIndex, childrenLength, mediaRef, onExit]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user