Browse Source

Prevent adding in UndoManager empty changes

pull/3563/head
Artur Arseniev 5 years ago
parent
commit
bb20dbe6a6
  1. 8
      src/undo_manager/index.js

8
src/undo_manager/index.js

@ -25,7 +25,7 @@
*/ */
import UndoManager from 'backbone-undo'; import UndoManager from 'backbone-undo';
import { isArray, isBoolean } from 'underscore'; import { isArray, isBoolean, isEmpty } from 'underscore';
export default () => { export default () => {
let em; let em;
@ -80,12 +80,16 @@ export default () => {
if (hasSkip(opt)) { if (hasSkip(opt)) {
return; return;
} else { } else {
const after = object.toJSON({ fromUndo });
const result = { const result = {
object, object,
before: beforeCache, before: beforeCache,
after: object.toJSON({ fromUndo }) after
}; };
beforeCache = null; beforeCache = null;
// Skip undo in case of empty changes
if (isEmpty(after)) return;
return result; return result;
} }
} }

Loading…
Cancel
Save