mirror of
https://github.com/maputnik/editor.git
synced 2026-03-22 18:20:01 +00:00
Fix redo issue
This commit is contained in:
@@ -87,4 +87,39 @@ describe("history", () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not redo after undo and value change", () => {
|
||||||
|
when.setStyle("geojson");
|
||||||
|
when.modal.open();
|
||||||
|
when.modal.fillLayers({
|
||||||
|
id: "step 1",
|
||||||
|
type: "background",
|
||||||
|
});
|
||||||
|
|
||||||
|
when.modal.open();
|
||||||
|
when.modal.fillLayers({
|
||||||
|
id: "step 2",
|
||||||
|
type: "background",
|
||||||
|
});
|
||||||
|
|
||||||
|
when.typeKeys(undoKeyCombo);
|
||||||
|
when.typeKeys(undoKeyCombo);
|
||||||
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ layers: [] });
|
||||||
|
|
||||||
|
when.modal.open();
|
||||||
|
when.modal.fillLayers({
|
||||||
|
id: "step 3",
|
||||||
|
type: "background",
|
||||||
|
});
|
||||||
|
|
||||||
|
when.typeKeys(redoKeyCombo);
|
||||||
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||||
|
layers: [
|
||||||
|
{
|
||||||
|
id: "step 3",
|
||||||
|
type: "background",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,10 +19,13 @@ export class RevisionStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addRevision(revision: StyleSpecification & {id: string}) {
|
addRevision(revision: StyleSpecification & {id: string}) {
|
||||||
//TODO: compare new revision style id with old ones
|
// clear any "redo" revisions once a change is made
|
||||||
//and ensure that it is always the same id
|
// and ensure current index is at end of list
|
||||||
|
this.revisions = this.revisions.slice(0, this.currentIdx + 1);
|
||||||
|
|
||||||
this.revisions.push(revision)
|
this.revisions.push(revision)
|
||||||
this.currentIdx++
|
this.currentIdx++
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
undo() {
|
undo() {
|
||||||
|
|||||||
Reference in New Issue
Block a user