* Returns an ID for the logical "row" this input is part of. A "row" is * bounded by a previous/next connection, a statement input, or a block stack * boundary; all blocks/inputs nested inside of one of those are conceptually * part of its same row. * * @internal
()
| 370 | * @internal |
| 371 | */ |
| 372 | getRowId(): string { |
| 373 | const inputs = this.getSourceBlock().inputList; |
| 374 | |
| 375 | // The first visible input shares the block's row id; this also covers |
| 376 | // the collapsed-input placeholder, since every other input is hidden. |
| 377 | if (this === inputs.find((i) => i.isVisible())) { |
| 378 | return (this.getSourceBlock() as BlockSvg).getRowId(); |
| 379 | } |
| 380 | |
| 381 | // Fallback when inputs[0] itself is hidden. |
| 382 | if (this === inputs[0]) { |
| 383 | return (this.getSourceBlock() as BlockSvg).getRowId(); |
| 384 | } |
| 385 | |
| 386 | const inputIndex = inputs.indexOf(this); |
| 387 | const precedingStatementInput = |
| 388 | inputs[inputIndex - 1].connection?.type === ConnectionType.NEXT_STATEMENT; |
| 389 | |
| 390 | // Each subsequent statement input or value input following a statement |
| 391 | // input is on its own row and has its own row ID. |
| 392 | if ( |
| 393 | this.connection?.type === ConnectionType.NEXT_STATEMENT || |
| 394 | precedingStatementInput |
| 395 | ) { |
| 396 | return `${this.getSourceBlock().id}-input${inputIndex}`; |
| 397 | } |
| 398 | |
| 399 | // Value inputs have the same row ID as their preceding input, since |
| 400 | // they're all on one row. |
| 401 | return inputs[inputIndex - 1].getRowId(); |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Returns a derived accessibility label for this input: field row text plus |
nothing calls this directly
no test coverage detected