fix multi-shortcut issue (#856)
This commit is contained in:
committed by
GitHub
parent
1c23d4fd11
commit
4f343fdb8f
@@ -1,3 +1,4 @@
|
|||||||
|
import { useMemo } from 'react';
|
||||||
import {
|
import {
|
||||||
useKeyboardShortcut,
|
useKeyboardShortcut,
|
||||||
type KeyboardShortcutOptions,
|
type KeyboardShortcutOptions,
|
||||||
@@ -33,8 +34,13 @@ export function createSemanticHook<A extends Action>(action: A) {
|
|||||||
// Use 'when' as alias for 'enabled' if provided
|
// Use 'when' as alias for 'enabled' if provided
|
||||||
const isEnabled = when !== undefined ? when : enabled;
|
const isEnabled = when !== undefined ? when : enabled;
|
||||||
|
|
||||||
const keys = getKeysFor(action, scope);
|
// Memoize to get stable array references and prevent unnecessary re-registrations
|
||||||
const binding = getBindingFor(action, scope);
|
const keys = useMemo(() => getKeysFor(action, scope), [action, scope]);
|
||||||
|
|
||||||
|
const binding = useMemo(
|
||||||
|
() => getBindingFor(action, scope),
|
||||||
|
[action, scope]
|
||||||
|
);
|
||||||
|
|
||||||
const keyboardShortcutOptions: KeyboardShortcutOptions = {};
|
const keyboardShortcutOptions: KeyboardShortcutOptions = {};
|
||||||
if (enableOnContentEditable !== undefined)
|
if (enableOnContentEditable !== undefined)
|
||||||
|
|||||||
Reference in New Issue
Block a user