Git Product home page Git Product logo

Comments (11)

bcakmakoglu avatar bcakmakoglu commented on May 10, 2024

Can you add a sandbox as well?
Here's a template: https://codesandbox.io/s/frosty-minsky-20b0ge

That would be very helpful thank you :)

from vue-flow.

bcakmakoglu avatar bcakmakoglu commented on May 10, 2024

Using your instructions doesn't yield the results you describe.
All the edges seem to be deleted properly.

As mentioned, please provide a sandbox reproduction please :)

from vue-flow.

insssomniac avatar insssomniac commented on May 10, 2024

For some reason i have an error during running the sandbox, so i just created the repository and recorded the video.
Repo: https://github.com/insssomniac/vue-flow-example , just clone it, install and run npm run serve
Video: https://drive.google.com/file/d/1qvd8SP2lU--ZHR3uxPgONOPWZ3L3q503/view?usp=sharing

To create a node, just drag&drop it from the top pane
To remove a node, dbl-click to it

from vue-flow.

bcakmakoglu avatar bcakmakoglu commented on May 10, 2024

Mh....I am using your repo and can't seem to be able to reproduce the issue as in your video.

Screen.Recording.2022-10-04.at.16.02.10.mov

Are there any specific logs when the issue appears?
What browser are you using?

from vue-flow.

insssomniac avatar insssomniac commented on May 10, 2024

Very strange. I'm on Chrome Version 106.0.5249.61 (Official Build) (64-bit) also tried on Firefox, and had the same issue. Also my colleague faced to the same issue
I recorded again with console opened, maybe it will help
vue-flow-error-2nd.webm

from vue-flow.

bcakmakoglu avatar bcakmakoglu commented on May 10, 2024

I can't view the video you linked, can you link it in a different way? 😄

from vue-flow.

bcakmakoglu avatar bcakmakoglu commented on May 10, 2024

Also can you make sure that your browser isn't somehow overwriting the css rule for .vue-flow__edges?

It needs to have the overflow rule

.vue-flow__edges {
  overflow: visible;
}

from vue-flow.

insssomniac avatar insssomniac commented on May 10, 2024

If you just open the video in the new tab, it doesn't show? :))
prev. video, from post above (2): https://drive.google.com/file/d/1fcfoT21kOW3LFSsh6nvCAYat2Hrxqfb3/view?usp=sharing

3-rd video, i showed here elements list, and it seems edge really disapearing https://drive.google.com/file/d/1bl7xeJh-rqbzBMbrKaepwP3Y4j5sT1VR/view?usp=sharing

from vue-flow.

bcakmakoglu avatar bcakmakoglu commented on May 10, 2024

@insssomniac

Replace the following code:

const {
  onNodeDoubleClick,
  onNodeClick,
  onPaneClick,
  onEdgeClick,
  toObject,
  onConnect,
  addNodes,
  addEdges,
  getSelectedNodes,
  applyEdgeChanges,
  applyNodeChanges,
  project
} = useVueFlow()

// ...

onNodeDoubleClick((e) => {
  if (confirm('Delete node?')) {
    applyNodeChanges([{type: 'remove', id: e.node.id}])
  }
})

onEdgeClick((e) => {
  if (confirm('Delete edge?')) {
    applyEdgeChanges([{ type: 'remove', id: e.edge.id }])
  }
})

with

const {
  onNodeDoubleClick,
  onNodeClick,
  onPaneClick,
  onEdgeClick,
  toObject,
  onConnect,
  addNodes,
  addEdges,
  getSelectedNodes,
  removeEdges,
  removeNodes,
  project
} = useVueFlow()

onNodeDoubleClick((e) => {
  if (confirm('Delete node?')) {
		removeNodes([e.node])
  }
})

onEdgeClick((e) => {
  if (confirm('Delete edge?')) {
    removeEdges([e.edge])
  }
})

In most cases you should not be using applyNodeChanges or applyEdgeChanges yourself and if you do then only to intercept the change handlers (for some possible validation for example).
Instead use the appropriate actions for that like addNodes or removeNodes etc. which will emit these changes through the proper channels and you should not have any issues as seen in the clips.

What happens here is that you remove the node by applying the change yourself, thus Vue Flow never checks if any edges should be removed as well.
After the node gets removed, the edge is seen as "orphaned" and there will be an attempt to remove it.
That apparently doesn't work properly in this case, which I will fix, and instead it removes an edge at another index position.

Anyway, these issues don't appear when you use the actions instead :)

from vue-flow.

insssomniac avatar insssomniac commented on May 10, 2024

@bcakmakoglu removeNodes([e.node]) instead applyNodeChanges solved the issue, thanks!
I don't remeber why i decided to use applyNodeChanges, but i'll replace as you said for nodes and for edges.

from vue-flow.

bcakmakoglu avatar bcakmakoglu commented on May 10, 2024

@insssomniac
With 0.4.41 it should work with applyEdgeChanes as well - you should still use removeEdges instead though 😄

from vue-flow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.