diff --git a/packages/studio-ui/src/components/UndoRedo.tsx b/packages/studio-ui/src/components/UndoRedo.tsx index c64d488ff..6c49b10cd 100644 --- a/packages/studio-ui/src/components/UndoRedo.tsx +++ b/packages/studio-ui/src/components/UndoRedo.tsx @@ -22,15 +22,18 @@ export default function UndoRedo(): JSX.Element { redo(); }, [redo]); - const handleUndoKeydown = useCallback((event: KeyboardEvent) => { - event.preventDefault() - if ((event.ctrlKey || event.metaKey) && event.key === "z") { - undo() - } - }, [undo]) + const handleUndoKeydown = useCallback( + (event: KeyboardEvent) => { + event.preventDefault(); + if ((event.ctrlKey || event.metaKey) && event.key === "z") { + undo(); + } + }, + [undo] + ); useEffect(() => { - document.addEventListener("keydown", handleUndoKeydown) + document.addEventListener("keydown", handleUndoKeydown); }, [handleUndoKeydown]); const disableUndo = pastStates.length === 0; diff --git a/packages/studio-ui/tests/components/UndoRedo.test.tsx b/packages/studio-ui/tests/components/UndoRedo.test.tsx index 50b47860c..043f84453 100644 --- a/packages/studio-ui/tests/components/UndoRedo.test.tsx +++ b/packages/studio-ui/tests/components/UndoRedo.test.tsx @@ -51,7 +51,7 @@ describe("Undo/redo", () => { expect(useStudioStore.getState().pages.activeComponentUUID).toBe( "searchbar-uuid" ); - await userEvent.keyboard('{Control>}z{/Control}') + await userEvent.keyboard("{Control>}z{/Control}"); expect(useStudioStore.getState().pages.activeComponentUUID).toBeUndefined(); }); @@ -60,7 +60,7 @@ describe("Undo/redo", () => { expect(useStudioStore.getState().pages.activeComponentUUID).toBe( "searchbar-uuid" ); - await userEvent.keyboard('{Meta>}z{/Meta}') + await userEvent.keyboard("{Meta>}z{/Meta}"); expect(useStudioStore.getState().pages.activeComponentUUID).toBeUndefined(); });