Fixes #6656 Is this the right way to implement keyboard listeners? Please let me know, I'll make the changes accordingly. :) https://github.com/user-attachments/assets/af71d340-ead9-4659-81e6-a440522a194f --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
21 lines
563 B
TypeScript
21 lines
563 B
TypeScript
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
|
import { useEffect } from 'react';
|
|
|
|
export const useHotkeyScopeOnMount = (hotkeyScope: string) => {
|
|
const {
|
|
goBackToPreviousHotkeyScope,
|
|
setHotkeyScopeAndMemorizePreviousScope,
|
|
} = usePreviousHotkeyScope();
|
|
|
|
useEffect(() => {
|
|
setHotkeyScopeAndMemorizePreviousScope(hotkeyScope);
|
|
return () => {
|
|
goBackToPreviousHotkeyScope();
|
|
};
|
|
}, [
|
|
hotkeyScope,
|
|
setHotkeyScopeAndMemorizePreviousScope,
|
|
goBackToPreviousHotkeyScope,
|
|
]);
|
|
};
|