fix(store): remove action not properly removing elements
This commit is contained in:
@@ -8,18 +8,19 @@ export function getElements(xElements = 10, yElements = 10) {
|
|||||||
|
|
||||||
for (let y = 0; y < yElements; y++) {
|
for (let y = 0; y < yElements; y++) {
|
||||||
for (let x = 0; x < xElements; x++) {
|
for (let x = 0; x < xElements; x++) {
|
||||||
const position = { x: x * 100, y: y * 50 }
|
initialNodes.push({
|
||||||
const node = {
|
|
||||||
id: nodeId.toString(),
|
id: nodeId.toString(),
|
||||||
style: { width: 50, fontSize: 11 },
|
|
||||||
label: `Node ${nodeId}`,
|
label: `Node ${nodeId}`,
|
||||||
type: '',
|
style: (node) => {
|
||||||
position,
|
const style: Record<string, any> = { width: `50px`, fontSize: `11px`, zIndex: 1 }
|
||||||
|
if (node.selected) style.border = '1px solid red'
|
||||||
|
return style
|
||||||
|
},
|
||||||
|
position: { x: x * 100, y: y * 50 },
|
||||||
data: {
|
data: {
|
||||||
randomData: Math.floor(Math.random() * 1e3),
|
randomData: Math.floor(Math.random() * 1e3),
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
initialNodes.push(node)
|
|
||||||
|
|
||||||
if (recentNodeId && nodeId <= xElements * yElements) {
|
if (recentNodeId && nodeId <= xElements * yElements) {
|
||||||
initialEdges.push({
|
initialEdges.push({
|
||||||
|
|||||||
@@ -169,11 +169,23 @@ export default (state: State, getters: ComputedGetters): Actions => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const removeSelectedNodes: Actions['removeSelectedNodes'] = (nodes) => {
|
const removeSelectedNodes: Actions['removeSelectedNodes'] = (nodes) => {
|
||||||
nodeSelectionHandler(nodes, false)
|
if (!nodes.length) return nodeSelectionHandler(nodes, false)
|
||||||
|
|
||||||
|
const nodeIds = nodes.map((n) => n.id)
|
||||||
|
|
||||||
|
const changedNodes = nodeIds.map((nodeId) => createSelectionChange(nodeId, false))
|
||||||
|
|
||||||
|
if (changedNodes.length) state.hooks.nodesChange.trigger(changedNodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeSelectedEdges: Actions['removeSelectedEdges'] = (edges) => {
|
const removeSelectedEdges: Actions['removeSelectedEdges'] = (edges) => {
|
||||||
edgeSelectionHandler(edges, false)
|
if (!edges.length) edgeSelectionHandler(edges, false)
|
||||||
|
|
||||||
|
const edgeIds = edges.map((e) => e.id)
|
||||||
|
|
||||||
|
const changedEdges = edgeIds.map((edgeId) => createSelectionChange(edgeId, false))
|
||||||
|
|
||||||
|
if (changedEdges.length) state.hooks.edgesChange.trigger(changedEdges)
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeSelectedElements: Actions['removeSelectedElements'] = (elements) => {
|
const removeSelectedElements: Actions['removeSelectedElements'] = (elements) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user