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

Loading…
Cancel
Save