Comfy-Org / Comfy-Org/ComfyUI_frontend

Refactor: Normalize graph-canvas targetElementId at keybinding registration time

Open
#9,497 0 comments 0 reactions 1 assignee Claimed by @Myestery View on GitHub
developer experience
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

When a keybinding specifies `targetElementId: 'graph-canvas'`, it is currently normalized to `'graph-canvas-container'` at event-handling time inside `keybindHandler` in `src/platform/keybindings/keybindingService.ts`.

It would be cleaner to perform this normalization at **keybinding registration time** instead (e.g., in `registerCoreKeybindings` or `addDefaultKeybinding`), and update all core bindings in `src/platform/keybindings/defaults.ts` to use `graph-canvas-container` directly, removing the runtime special-case from the handler.

## Context

- Raised as a nit during review of PR #9459 by @pythongosssss: https://github.com/Comfy-Org/ComfyUI_frontend/pull/9459#discussion_r2896907201
- Requested by @Myestery

## Suggested Approach

1. Update all entries in `CORE_KEYBINDINGS` (defaults.ts) that have `targetElementId: 'graph-canvas'` to use `targetElementId: 'graph-canvas-container'` instead.
2. Remove the runtime normalization block in `keybindHandler` that remaps `'graph-canvas'` → `'graph-canvas-container'`.
3. Optionally, apply the same normalization in `addDefaultKeybinding` / `addUserKeybinding` to guard against external callers passing the old ID.

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-9497-Refactor-Normalize-graph-canvas-targetElementId-at-keybinding-registration-time-31b6d73d36508196871bfd2d86b0068a) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.