Skip to content

Commit 0e1d934

Browse files
committed
chore: better code
1 parent 083f40f commit 0e1d934

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/components/editor/components/toolbar/selection-toolbar/hooks/useKeyboardNavigation.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, useEffect, useRef, useState } from 'react';
22

3-
import { createHotkey,HOT_KEY_NAME } from '@/utils/hotkeys';
3+
import { createHotkey, HOT_KEY_NAME } from '@/utils/hotkeys';
44

55
interface UseKeyboardNavigationProps {
66
itemCount: number;
@@ -20,7 +20,6 @@ export function useKeyboardNavigation({ itemCount, onSelect, onClose, isOpen }:
2020
}
2121

2222
const handleKeyDown = (e: KeyboardEvent) => {
23-
// 只在按下上下键时阻止默认行为
2423
if (createHotkey(HOT_KEY_NAME.UP)(e) || createHotkey(HOT_KEY_NAME.DOWN)(e)) {
2524
e.preventDefault();
2625
e.stopPropagation();
@@ -40,7 +39,6 @@ export function useKeyboardNavigation({ itemCount, onSelect, onClose, isOpen }:
4039
}
4140
};
4241

43-
// 使用 capture 阶段来确保在事件到达编辑器之前处理
4442
document.addEventListener('keydown', handleKeyDown, true);
4543
return () => {
4644
document.removeEventListener('keydown', handleKeyDown, true);

0 commit comments

Comments
 (0)