Skip to content

Commit

Permalink
Fix undo/redo key combination
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Apr 10, 2021
1 parent 1feaec5 commit 7147dca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/useEditable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const setCurrentRange = (range: Range) => {
};

const isUndoRedoKey = (event: KeyboardEvent): boolean =>
(event.metaKey || event.ctrlKey) && !event.altKey && event.key === 'z';
(event.metaKey || event.ctrlKey) && !event.altKey && event.code === 'KeyZ';

const toString = (element: HTMLElement): string => {
const queue: Node[] = [element.firstChild!];
Expand Down Expand Up @@ -285,7 +285,7 @@ export const useEditable = (

let _trackStateTimestamp: number;
const trackState = (ignoreTimestamp?: boolean) => {
if (!elementRef.current || state.position) return;
if (!elementRef.current || !state.position) return;

const content = toString(element);
const position = getPosition(element);
Expand Down

0 comments on commit 7147dca

Please sign in to comment.