Coder Social home page Coder Social logo

Comments (2)

bcakmakoglu avatar bcakmakoglu commented on July 19, 2024 1

To address some of the things in here

edge.updatable should add the EdgeAnchor to both the target and source ends if true, or to just the designated end if set to "target" or "source".

This is already the case. If edge.updatable is true, both EdgeAnchors will appear etc.

This should override whatever props are set on the ReactFlow component.

This is also already the case, edge.updatable always has precedence over the global edgesUpdatable prop

It feels weird that the onEdgeUpdate callback is the way to toggle "updatable edges". I'm using onEdgesChange for the actual logic of all changes to my edges [...]

onEdgesChange is not a replacement for onEdgeUpdate so I'm not sure where the assumption comes from that you can use one or the other.
onEdgesChange is meant to communicate internal changes to the user, like selecting, adding or removing an edge.
Updates are not part of the changes that are pushed through onEdgesChange (although it could be argued that these should also go in there ^^)

The reasoning, at least from my point of view, for the requirement of passing an actual onEdgeUpdate handler is that you as a user have to handle the update. ReactFlow doesn't make assumptions about how an edge should be updated, it only communicates to you that these are the params of the update. You can do whatever you want with the params: maybe you want to validate the update first, maybe you want to modify the edge params before the updating, maybe you wanna do something else entirely.

Assuming that onEdgeUpdate was not required and it RF would handle the update for you, I could see people opening Issues just like this one complaining why RF assumes to know how the update should be handled 😅
So imo I think having the users take care of this solves it pretty nicely and I don't quite see where the problem lies with passing a basic handler if that's all you need for your use-case?

Meanwhile edgesUpdatable bool seems to only exist to disable "updatable edges"?

More or less - if you passed an update handler and want to toggle the updatable behavior, you can turn it on and off globally with this prop, although as mentioned previously edge.updatable always has precedence when determining if an edge is updatable.

from xyflow.

IanLondon avatar IanLondon commented on July 19, 2024

That makes sense, I didn't realize until I started playing with it that the onEdgeUpdate doesn't dispatch any EdgeRemoveChange | EdgeAddChange to onEdgesChange.

from xyflow.

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.