AlrasheedA / st-link-analysis

A custom Streamlit component for link analysis, built with Cytoscape.js and Streamlit.
https://pypi.org/project/st-link-analysis/
MIT License
41 stars 3 forks source link

Remove event #24

Closed controllocked closed 2 weeks ago

controllocked commented 1 month ago

Hello. Thank you for adding functionality that enlarge possible manipulations with nodes!

I would like to ask you about removal action: is it possible to turn this action off? I've tried to make this action do nothing, but it still deletes nodes.

AlrasheedA commented 1 month ago

Hello @controllocked, thank you for the feedback!

So you have a use case in which you want to enable node expansions, but disable removals (either delete key or the delete button), right?

If that's the case then unfortuantely no, currently you can only enable all or none of the node actions.

It is something that can be easily incorporated in the next version. Instead of passing True and False to the enable_node_actions parameter, the user will be able to pass the actions (e.g. node_actions=['expand', 'remove']) which allows for selecting only specific actions + makes it easier to incorporate more actions down the line.

Would appreciate your support in the following:

  1. Sharing an example scenario where only node expansions are required.
  2. Sharing your thoughts on the above proposal using node_actions parameter, and whether it will address your requirement.

Thank you!

controllocked commented 1 month ago

Thank you for your response @AlrasheedA .

  1. I am using node expansion in order to trigger st.dialog for more detailed information about node.
  2. Yeah! Seems like perfect solution. It will definitely work for me.

Also is it possible to code a custom logic for remove action in the current version? I've tried, but it didn't work.

AlrasheedA commented 1 month ago

Thanks! I’ll include node_actions in the next version. ✅

On remove custom logic, Currently, you can’t prevent the remove action from deleting the selected nodes. To ensure a smoother and faster experience, the remove event immediately deletes the nodes on the client side (in JavaScript) and then sends the event to Python, so that the developer can update the elements accordingly & implement additional implement custom logic (excluding NOT removing the elements).

To disable this behavior, you could fork the repo and remove a single line of code in JavaScript at nodeActions.js Line #43

For now, I don’t plan to change this behavior, as removing that line introduces a delay that affects the user experience. However, I’m happy to explore other options if there’s a strong use case for it or if there’s a different approach that maintains the immediate feedback for users.