diff --git a/cypress/integration/ui/issues/issue-699.js b/cypress/integration/ui/issues/issue-699.js new file mode 100644 index 00000000..98dd8fa8 --- /dev/null +++ b/cypress/integration/ui/issues/issue-699.js @@ -0,0 +1,29 @@ +import { + visitAndApproveStorage +} from '../../../support/ui-test-helper.js' + +// See https://github.com/SVG-Edit/svgedit/issues/699 +describe('Fix issue 699', function () { + beforeEach(() => { + visitAndApproveStorage() + }) + + it('should not throw error when undoing and redoing convert to path for a rectangle', function () { + cy.get('#tool_rect') + .click({ force: true }) + cy.get('#svgcontent') + .trigger('mousedown', 150, 150, { force: true }) + .trigger('mousemove', 250, 200, { force: true }) + .trigger('mouseup', { force: true }) + cy.get('#tool_topath') // Check if undo redo is correct for tool_topath with tool_rect + .click({ force: true }) + cy.get('#tool_undo') + .click({ force: true }) + cy.get('#tool_redo') + .click({ force: true }) + cy.get('#tool_undo') // Do twice just to make sure + .click({ force: true }) + cy.get('#tool_redo') + .click({ force: true }) + }) +}) diff --git a/src/svgcanvas/utilities.js b/src/svgcanvas/utilities.js index f55098bd..c4f84a82 100644 --- a/src/svgcanvas/utilities.js +++ b/src/svgcanvas/utilities.js @@ -760,11 +760,11 @@ export const convertToPath = (elem, attrs, svgCanvas) => { } const { nextSibling } = elem - batchCmd.addSubCommand(new svgCanvas.history.RemoveElementCommand(elem, nextSibling, parent)) - batchCmd.addSubCommand(new svgCanvas.history.InsertElementCommand(path)) - + batchCmd.addSubCommand(new svgCanvas.history.RemoveElementCommand(elem, nextSibling, elem.parentNode)) svgCanvas.clearSelection() elem.remove() + + batchCmd.addSubCommand(new svgCanvas.history.InsertElementCommand(path)) path.setAttribute('id', id) path.removeAttribute('visibility') svgCanvas.addToSelection([path], true)