Comments (5)
To address the edge deletion issue and improve usability in your project, here are some targeted solutions:
-
Edge Deletion Not Working: The problem might stem from the event listener not correctly identifying the delete key press or not having the correct edge ID to perform the deletion. Ensure your event listener for the delete action is correctly set up to capture the
Delete
orBackspace
key presses and is calling thedeleteEdge
function with the correct edge ID. Here's a snippet to guide you:document.addEventListener("keydown", (event) => { if ((event.key === "Delete" || event.key === "Backspace") && lastSelection) { event.preventDefault(); // Assuming deleteNode and deleteEdge functions are defined elsewhere deleteEdge(lastSelection.edges.map((edge) => edge.id)); } });
Make sure
lastSelection
accurately captures the selected edges and thatdeleteEdge
is implemented to handle edge deletion based on the edge's ID. -
Improving Edge Visibility: To make an edge more visible when selected, consider dynamically adjusting its style based on its selection state. This involves modifying the edge's style properties when it's selected to make it stand out. You'll need to track edge selection and apply style changes accordingly.
-
Easier Edge Deletion via UI: Introducing a cross button (X) on the edge for easier deletion can enhance user interaction. This requires customizing the edge component to include a button when rendering edges and managing the button's visibility and the deletion logic upon interaction.
These steps should help you resolve the edge deletion issue and improve the user experience by making edges more visible when selected and easier to delete.
Details
Sources
- src/frontend/src/stores/flowStore.ts
- src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx
- src/frontend/src/stores/flowStore.ts
- src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx
- src/frontend/src/utils/reactflowUtils.ts
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
from langflow.
To resolve the issue where lastSelection
does not update with the edge's ID upon selection, ensuring that the onSelectionChange
callback is correctly implemented is crucial. This callback should update lastSelection
with the selected edge's information. If lastSelection
remains empty, it indicates that the selection event might not be capturing or updating the state as expected. Here's a quick check to ensure your callback is set up correctly:
const onSelectionChange = useCallback(
(flow: OnSelectionChangeParams): void => {
setLastSelection(flow);
},
[],
);
Ensure that OnSelectionChangeParams
correctly handles edge data and that setLastSelection
is being called with the right parameters.
For the UI improvements and making edge deletion more intuitive:
-
Highlight Selected Edges: Implement a function to visually highlight an edge when it's selected. This could involve changing the edge's stroke color or width to make it stand out.
-
Improve Edge Selection Detection: Adjust the hitbox size for edge selection or implement custom logic to ensure clicks near an edge path are detected accurately.
-
Delete Key Binding: Confirm that the delete key event listener is set up to identify when an edge is selected. It should call the
deleteEdge
function with the correct edge ID. Here's an example of how you might set up such an event listener:
useEffect(() => {
const onKeyDown = (event: KeyboardEvent) => {
if ((event.key === "Delete" || event.key === "Backspace") && lastSelection?.edges.length > 0) {
event.preventDefault();
deleteEdge(lastSelection.edges.map((edge) => edge.id));
}
};
document.addEventListener("keydown", onKeyDown);
return () => {
document.removeEventListener("keydown", onKeyDown);
};
}, [lastSelection, deleteEdge]);
- Visual Feedback on Selection: Ensure there's immediate visual feedback when an edge is selected, such as a change in color or a tooltip, to confirm it's ready for deletion.
Implementing these steps should help in resolving the edge deletion issue and improving the overall user experience in your project.
Details
Sources
- src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx
- src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx
- src/frontend/src/stores/flowStore.ts
- src/frontend/src/stores/flowStore.ts
- src/frontend/src/stores/flowsManagerStore.ts
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
from langflow.
To tackle the issue where lastSelection
doesn't contain the selected edge's information before deletion, despite the edge being correctly shown as selected, consider the following steps:
-
Ensure Event Firing: Verify that the
onSelectionChange
event consistently fires and updateslastSelection
whenever an edge is selected. Adding console logs or using a debugger can help confirm thatsetLastSelection
is called with the correct edge information. -
Check Conditional Logic: Examine any conditional logic within your event handlers or
useEffect
hooks that might preventlastSelection
from updating. It's crucial that no conditions inadvertently block the state update. -
Review State Management: Look for any parts of your code that might unintentionally reset or overwrite
lastSelection
. This includes all occurrences ofsetLastSelection
and any other state manipulations that could affect it. -
Direct Edge Deletion Handling: If the problem persists, consider a more direct approach to handling edge deletion that doesn't rely on
lastSelection
. Managing edge selection state more explicitly and using this state for deletion could offer a more reliable solution.
By focusing on these areas, you should be able to ensure that lastSelection
accurately reflects the selected edge's information, allowing for successful deletion.
Details
Sources
- src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx
- src/frontend/src/stores/flowStore.ts
- src/frontend/src/pages/FlowPage/components/SelectionMenuComponent/index.tsx
- src/frontend/src/utils/utils.ts
- src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx
- src/frontend/src/stores/flowsManagerStore.ts
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
from langflow.
@dosu When I select edge and press delete, the edge id or info does not appear in lastselection
lastSelection: {"nodes":[],"edges":[]}
from langflow.
@dosu The edge is correctly shown here when selected
const onSelectionChange = useCallback(
(flow: OnSelectionChangeParams): void => {
setLastSelection(flow);
},
[],
);
However, the lastSelection is empty here
if (!isWrappedWithClass(event, "nodelete")) {
if (
(event.key === "Delete" || event.key === "Backspace") &&
lastSelection
) {
event.preventDefault();
takeSnapshot();
console.log(`lastSelection: ${JSON.stringify(lastSelection)}`);
console.log(`DeleteNode ${lastSelection.nodes.map((node) => node.id)}`);
deleteNode(lastSelection.nodes.map((node) => node.id));
console.log(`DeleteEdge ${lastSelection.edges.map((edge) => edge.id)}`);
deleteEdge(lastSelection.edges.map((edge) => edge.id));
}
}
};
```
However, If I hardcode the id here for deleteEdge then it works. So for sure the problem is that lastselection don't have the selected edge here before deleting it.
from langflow.
Related Issues (20)
- Astra Connector needs a truncate operation
- Astra UI component: Astra URL component is not validated on entry
- On a component box, it is not clear that the red "X" will re-run the component unless you hover over or click HOT 1
- ERR by redis : RedisCache.upsert() got an unexpected keyword argument 'lock' HOT 1
- version HOT 3
- Cannot Enter Store API Key on Self-Hosted LangFlow Instance HOT 1
- Get Openai model list from api HOT 2
- OpenAI chat with no max new tokens
- I can't connect the new api on the langflow pre release HOT 5
- I can't connect api to the new langflow pre release this is the body HOT 3
- Error in API cURL option, JSON malformed and missing closing } on tweaks object HOT 2
- Lock type inconsistency between set_cache and upsert methods HOT 3
- flow disappears from hugging face HOT 6
- poetry going in an infinite loop in installing spacy HOT 2
- pre-release version Installation with pip failed and spacy install loop HOT 6
- Database Connection Pool Settings HOT 1
- RAG and Tool usage , at the same time HOT 2
- Pinecone Search Component not returning records HOT 2
- Langflow run | Migration Issue HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from langflow.