MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / handleKeyDown

Function handleKeyDown

yaml-flow-editor/src/App.tsx:415–444  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

413 // Delete/Backspace for selected inner steps
414 useEffect(() => {
415 const handleKeyDown = (e: KeyboardEvent) => {
416 if (e.key !== 'Delete' && e.key !== 'Backspace') return;
417 if (!selectedInnerStep) return;
418
419 // Don't intercept when typing in inputs
420 const el = document.activeElement;
421 if (
422 el instanceof HTMLInputElement ||
423 el instanceof HTMLTextAreaElement ||
424 (el as HTMLElement)?.isContentEditable
425 ) return;
426
427 e.preventDefault();
428 e.stopPropagation();
429
430 setNodes((nodes) =>
431 nodes.map((node) => {
432 if (node.id === selectedInnerStep.parentNodeId) {
433 const nodeData = node.data as Record<string, unknown>;
434 const pathParts = selectedInnerStep.branch.split('.');
435 return {
436 ...node,
437 data: updateNestedStructure(nodeData, pathParts, selectedInnerStep.stepIndex, null),
438 };
439 }
440 return node;
441 })
442 );
443 selectInnerStep(null);
444 };
445
446 window.addEventListener('keydown', handleKeyDown, true);
447 return () => window.removeEventListener('keydown', handleKeyDown, true);

Callers

nothing calls this directly

Calls 1

updateNestedStructureFunction · 0.90

Tested by

no test coverage detected