fix: Visit all nodes in getNextSibling and getPreviousSibling (#9080)

* WIP on line by line navigation

Doesn't work, likely due to isValid check.

* Add all inputs to the list of siblings

* Fix formatting

* Add tests

* Remove dupe keys
This commit is contained in:
RoboErikG
2025-05-21 16:42:22 -07:00
committed by GitHub
parent 6dbd7b84be
commit e4d7245e86
2 changed files with 113 additions and 13 deletions

View File

@@ -57,7 +57,7 @@ export class BlockNavigationPolicy implements INavigationPolicy<BlockSvg> {
* Returns the next peer node of the given block.
*
* @param current The block to find the following element of.
* @returns The first block of the next stack if the given block is a terminal
* @returns The first node of the next input/stack if the given block is a terminal
* block, or its next connection.
*/
getNextSibling(current: BlockSvg): IFocusableNode | null {
@@ -70,12 +70,10 @@ export class BlockNavigationPolicy implements INavigationPolicy<BlockSvg> {
let siblings: (BlockSvg | Field)[] = [];
if (parent instanceof BlockSvg) {
for (let i = 0, input; (input = parent.inputList[i]); i++) {
if (input.connection) {
siblings.push(...input.fieldRow);
const child = input.connection.targetBlock();
if (child) {
siblings.push(child as BlockSvg);
}
siblings.push(...input.fieldRow);
const child = input.connection?.targetBlock();
if (child) {
siblings.push(child as BlockSvg);
}
}
} else if (parent instanceof WorkspaceSvg) {
@@ -114,12 +112,10 @@ export class BlockNavigationPolicy implements INavigationPolicy<BlockSvg> {
let siblings: (BlockSvg | Field)[] = [];
if (parent instanceof BlockSvg) {
for (let i = 0, input; (input = parent.inputList[i]); i++) {
if (input.connection) {
siblings.push(...input.fieldRow);
const child = input.connection.targetBlock();
if (child) {
siblings.push(child as BlockSvg);
}
siblings.push(...input.fieldRow);
const child = input.connection?.targetBlock();
if (child) {
siblings.push(child as BlockSvg);
}
}
} else if (parent instanceof WorkspaceSvg) {