Fix undo on converting rectangle to path creating an exception (#703)

master
km384 2022-01-12 18:17:56 +05:30 committed by GitHub
parent 0a6cce903e
commit 7704bc436c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 3 deletions

View File

@ -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 })
})
})

View File

@ -760,11 +760,11 @@ export const convertToPath = (elem, attrs, svgCanvas) => {
} }
const { nextSibling } = elem const { nextSibling } = elem
batchCmd.addSubCommand(new svgCanvas.history.RemoveElementCommand(elem, nextSibling, parent)) batchCmd.addSubCommand(new svgCanvas.history.RemoveElementCommand(elem, nextSibling, elem.parentNode))
batchCmd.addSubCommand(new svgCanvas.history.InsertElementCommand(path))
svgCanvas.clearSelection() svgCanvas.clearSelection()
elem.remove() elem.remove()
batchCmd.addSubCommand(new svgCanvas.history.InsertElementCommand(path))
path.setAttribute('id', id) path.setAttribute('id', id)
path.removeAttribute('visibility') path.removeAttribute('visibility')
svgCanvas.addToSelection([path], true) svgCanvas.addToSelection([path], true)