Skip to content

Fix Clicking on "Save Video" Node Video widget and press delete will trigger the entire graph to delete. #4329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

BenraouaneSoufiane
Copy link

@BenraouaneSoufiane BenraouaneSoufiane commented Jul 2, 2025

Hello, this pull fix this issue: #4216, I found the issue does not related with commandStore, keybindingService or even with node selection
the main reason that cause this issue is the video element capture the del press (keydown' event) instead litegraph.js, so I've remove the selected node manually when clicking the video then press del
Here's a video about the fix (sorry screenrec not works as expected this time)
https://youtu.be/z4YFia6YniY

@BenraouaneSoufiane BenraouaneSoufiane requested a review from a team as a code owner July 2, 2025 10:26
@BenraouaneSoufiane BenraouaneSoufiane marked this pull request as draft July 2, 2025 10:27
@christian-byrne
Copy link
Contributor

Thanks for working on this fix! I was looking at the issue and noticed that we already have keyboard event filtering logic in the keybinding service.

Would it be possible to handle this more simply by adding a check in src/services/keybindingService.ts after line 39? Something like:

// Prevent Delete key on media elements
if (event.key === 'Delete' && (target.tagName === 'VIDEO' || target.tagName === 'AUDIO')) {
  return
}

This would follow the same pattern we use for text inputs and would be just a few lines instead of the current approach. It seems like the keybinding service is already the central place where we filter keyboard events before they reach LiteGraph.

Also, it looks like the useContextMenuOverride composable might be unrelated to the video delete issue - could that potentially be moved to a separate PR?

@christian-byrne
Copy link
Contributor

Also make sure to install with npm install and run some of the scripts like npm run lint:fix and npm run format

@BenraouaneSoufiane
Copy link
Author

Thanks for working on this fix! I was looking at the issue and noticed that we already have keyboard event filtering logic in the keybinding service.

Would it be possible to handle this more simply by adding a check in src/services/keybindingService.ts after line 39? Something like:

// Prevent Delete key on media elements
if (event.key === 'Delete' && (target.tagName === 'VIDEO' || target.tagName === 'AUDIO')) {
  return
}

This would follow the same pattern we use for text inputs and would be just a few lines instead of the current approach. It seems like the keybinding service is already the central place where we filter keyboard events before they reach LiteGraph.

Also, it looks like the useContextMenuOverride composable might be unrelated to the video delete issue - could that potentially be moved to a separate PR?

Gooday, thank you for your reply/feedback, please keep in mind your suggested code prevent the deletion at all, do you need this? (I think it should delete only selected node, not stop it all), what do you think? remove my approache & use the suggested edit, or keeps it & ignore suggestion?

Sorry for the useContextMenuOverride, it was from other fix, anyway I've deleted it & undo changes concern graphcanvas.vue
Thanks

@BenraouaneSoufiane
Copy link
Author

Also make sure to install with npm install and run some of the scripts like npm run lint:fix and npm run format

Concern the linting of my edits, I did't found ts errors, concern the formatting, I'm using prettier for formating is that good?

@christian-byrne
Copy link
Contributor

You make a great point! You're right that my suggestion would prevent deletion entirely when focused on a video element.

Looking at the original issue more carefully, it seems the problem is that pressing Delete while focused on the video widget causes the entire graph to be deleted (not just selected nodes). This sounds like an unexpected behavior.

Could you clarify what the expected behavior should be when pressing Delete while focused on a video element? I see a few options:

  1. Delete key does nothing when video has focus (my original suggestion)
  2. Delete key removes only the selected nodes, not the entire graph (what your original code was doing)
  3. Delete key should work on the video element itself somehow (though I'm not sure what that would mean for a video)

For option 2, if we want to preserve the normal node deletion behavior, we could let the event propagate to LiteGraph but first ensure the canvas has proper focus:

// In keybindingService.ts
if (event.key === 'Delete' && target.tagName === 'VIDEO') {
  // Blur the video to ensure LiteGraph handles deletion properly
  (target as HTMLVideoElement).blur()
  // Let the event continue to LiteGraph
}

What do you think is the best approach? Also, thanks for removing the unrelated context menu changes!

@BenraouaneSoufiane
Copy link
Author

You make a great point! You're right that my suggestion would prevent deletion entirely when focused on a video element.

Looking at the original issue more carefully, it seems the problem is that pressing Delete while focused on the video widget causes the entire graph to be deleted (not just selected nodes). This sounds like an unexpected behavior.

Could you clarify what the expected behavior should be when pressing Delete while focused on a video element? I see a few options:

  1. Delete key does nothing when video has focus (my original suggestion)
  2. Delete key removes only the selected nodes, not the entire graph (what your original code was doing)
  3. Delete key should work on the video element itself somehow (though I'm not sure what that would mean for a video)

For option 2, if we want to preserve the normal node deletion behavior, we could let the event propagate to LiteGraph but first ensure the canvas has proper focus:

// In keybindingService.ts
if (event.key === 'Delete' && target.tagName === 'VIDEO') {
  // Blur the video to ensure LiteGraph handles deletion properly
  (target as HTMLVideoElement).blur()
  // Let the event continue to LiteGraph
}

What do you think is the best approach? Also, thanks for removing the unrelated context menu changes!

Gooday, thank you for your reply, in fact there are no issue with deletion in litgraph because when debug the selected node when clicking the video inside save video or even load video, it shows that the relative node are selected, so the video prevent the element to arrive to the litegraph (the video player uses e.stopPropagation() somehow), before arrive at this point I tried blur() that let me to confirm what happening (tried to simulate the keydown manually, & other things...)
I think to keep my approach because I didn't found other way to resolve this issue

@BenraouaneSoufiane BenraouaneSoufiane marked this pull request as ready for review July 16, 2025 08:49
@BenraouaneSoufiane BenraouaneSoufiane requested a review from a team as a code owner July 16, 2025 08:50
@BenraouaneSoufiane BenraouaneSoufiane changed the title [WIP] Fix Clicking on "Save Video" Node Video widget and press delete will trigger the entire graph to delete. Fix Clicking on "Save Video" Node Video widget and press delete will trigger the entire graph to delete. Jul 16, 2025
@BenraouaneSoufiane
Copy link
Author

@benceruleanlu can you take a look/merge?

@kevinpaik1
Copy link

Hi @BenraouaneSoufiane as mentioned in email to you, I'll be closing this PR. Thank you for your effort and interest in our bounty program.

@kevinpaik1 kevinpaik1 closed this Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants