Merge pull request #516 from orangemug/fix/prevent-default-browser-undo-redo

Prevent native browser undo/redo when handled by app
This commit is contained in:
Orange Mug 2019-05-19 18:52:14 +01:00 committed by GitHub
commit c947d9e3ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -225,20 +225,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);
}
}