From 979fc98e7060a7e250d8a96095b49a41b10317d0 Mon Sep 17 00:00:00 2001 From: orangemug Date: Sat, 18 May 2019 15:47:51 +0100 Subject: [PATCH] Prevent native browser undo/redo when handled by app --- src/components/App.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index 34216c8..35b3cf7 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -217,20 +217,24 @@ export default class App extends React.Component { }) } - handleKeyPress(e) { + handleKeyPress = (e) => { if(navigator.platform.toUpperCase().indexOf('MAC') >= 0) { if(e.metaKey && e.shiftKey && e.keyCode === 90) { + e.preventDefault(); this.onRedo(e); } else if(e.metaKey && e.keyCode === 90) { + e.preventDefault(); this.onUndo(e); } } else { if(e.ctrlKey && e.keyCode === 90) { + e.preventDefault(); this.onUndo(e); } else if(e.ctrlKey && e.keyCode === 89) { + e.preventDefault(); this.onRedo(e); } }