-
Notifications
You must be signed in to change notification settings - Fork 458
fix: spacebar panning in vueNodes mode #7807
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
base: main
Are you sure you want to change the base?
Changes from all commits
f5ac48c
2f8f525
1d1e16b
3cf19af
fc082d8
53bdf7f
d114b01
9427d7e
0e47f9f
a47081c
571bb51
f5cdee8
0972a46
0f6fb90
813f54b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1995,6 +1995,10 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |
| this._key_callback = this.processKey.bind(this) | ||
|
|
||
| canvas.addEventListener('keydown', this._key_callback, true) | ||
| // In Vue nodes mode, also listen on document for keydown since Vue elements may have focus | ||
| if (LiteGraph.vueNodesMode) { | ||
| document.addEventListener('keydown', this._key_callback, true) | ||
| } | ||
| // keyup event must be bound on the document | ||
| document.addEventListener('keyup', this._key_callback, true) | ||
|
|
||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
@@ -2019,14 +2023,24 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |
| const { canvas } = this | ||
|
|
||
| // Assertions: removing nullish is fine. | ||
| canvas.removeEventListener('pointercancel', this._mousecancel_callback!) | ||
| // Note: capture flag must match addEventListener for removal to work | ||
| canvas.removeEventListener( | ||
| 'pointercancel', | ||
| this._mousecancel_callback!, | ||
| true | ||
| ) | ||
| canvas.removeEventListener('pointerout', this._mouseout_callback!) | ||
| canvas.removeEventListener('pointermove', this._mousemove_callback!) | ||
| canvas.removeEventListener('pointerup', this._mouseup_callback!) | ||
| canvas.removeEventListener('pointerdown', this._mousedown_callback!) | ||
| canvas.removeEventListener('pointerup', this._mouseup_callback!, true) | ||
| canvas.removeEventListener('pointerdown', this._mousedown_callback!, true) | ||
| canvas.removeEventListener('wheel', this._mousewheel_callback!) | ||
| canvas.removeEventListener('keydown', this._key_callback!) | ||
| document.removeEventListener('keyup', this._key_callback!) | ||
| canvas.removeEventListener('keydown', this._key_callback!, true) | ||
| // Always remove document keydown listener - it may have been added if vueNodesMode | ||
| // was true during bindEvents, even if vueNodesMode has since changed | ||
| if (this._key_callback) { | ||
| document.removeEventListener('keydown', this._key_callback, true) | ||
| } | ||
| document.removeEventListener('keyup', this._key_callback!, true) | ||
| canvas.removeEventListener('contextmenu', this._doNothing) | ||
| canvas.removeEventListener('dragenter', this._doReturnTrue) | ||
|
|
||
|
|
@@ -3707,8 +3721,14 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |
| if (!graph) return | ||
|
|
||
| let block_default = false | ||
| // @ts-expect-error EventTarget.localName is not in standard types | ||
| if (e.target.localName == 'input') return | ||
| // Skip all text-editable surfaces to avoid blocking typing/selection/copy | ||
| const target = e.target as HTMLElement | null | ||
| if ( | ||
| target?.localName === 'input' || | ||
| target?.localName === 'textarea' || | ||
| target?.isContentEditable | ||
| ) | ||
| return | ||
|
Comment on lines
+3724
to
+3731
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Text-editable guard behavior is correct; prefer The new early-return and Delete/Backspace guard now correctly skip all text-editable surfaces, which fixes the prior regression where space / Ctrl+A / Ctrl+C / Delete could be intercepted while typing. That behavior looks solid. To better align with the “avoid type assertions in litegraph TS” guideline and the earlier suggestion for this block, consider tightening the typing with an Proposed cleanup of
|
||
|
|
||
| if (e.type == 'keydown') { | ||
| // TODO: Switch | ||
|
|
@@ -3744,9 +3764,12 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |
| // paste | ||
| this.pasteFromClipboard({ connectInputs: e.shiftKey }) | ||
| } else if (e.key === 'Delete' || e.key === 'Backspace') { | ||
| // delete or backspace | ||
| // @ts-expect-error EventTarget.localName is not in standard types | ||
| if (e.target.localName != 'input' && e.target.localName != 'textarea') { | ||
| // delete or backspace (but don't intercept when editing text) | ||
| if ( | ||
| target?.localName !== 'input' && | ||
| target?.localName !== 'textarea' && | ||
| !target?.isContentEditable | ||
| ) { | ||
| if (this.selectedItems.size === 0) { | ||
| this.#noItemsSelected() | ||
| return | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.