mirror of
https://github.com/google/blockly.git
synced 2026-05-20 02:50:12 +02:00
fix: Adjust keyboard navigation of external inputs (#9820)
* fix: Adjust keyboard navigation of external inputs * chore: Adjust docstrings * chore: Improve docs
This commit is contained in:
@@ -1977,7 +1977,10 @@ export class BlockSvg
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ID for the visual "row" this block is part of.
|
||||
* Returns an ID for the logical "row" this block 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
|
||||
*/
|
||||
|
||||
@@ -361,7 +361,10 @@ export class Input {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ID for the visual "row" this input is part of.
|
||||
* 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
|
||||
*/
|
||||
@@ -377,19 +380,17 @@ export class Input {
|
||||
const precedingStatementInput =
|
||||
inputs[inputIndex - 1].connection?.type === ConnectionType.NEXT_STATEMENT;
|
||||
|
||||
// Each subsequent (a) external input (b) statement input or (c) inline
|
||||
// input following a statement input is on its own row and has its own row
|
||||
// ID.
|
||||
// Each subsequent statement input or value input following a statement
|
||||
// input is on its own row and has its own row ID.
|
||||
if (
|
||||
!this.getSourceBlock().getInputsInline() ||
|
||||
this.connection?.type === ConnectionType.NEXT_STATEMENT ||
|
||||
precedingStatementInput
|
||||
) {
|
||||
return `${this.getSourceBlock().id}-input${inputIndex}`;
|
||||
}
|
||||
|
||||
// Value inputs on a inline input block have the same row ID as their
|
||||
// preceding input, since they're all on one row.
|
||||
// Value inputs have the same row ID as their preceding input, since
|
||||
// they're all on one row.
|
||||
return inputs[inputIndex - 1].getRowId();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
import {BlockSvg} from '../../block_svg.js';
|
||||
import {ConnectionType} from '../../connection_type.js';
|
||||
import {Field} from '../../field.js';
|
||||
import {getFocusManager} from '../../focus_manager.js';
|
||||
import {Icon} from '../../icons/icon.js';
|
||||
@@ -182,24 +181,6 @@ export class Navigator {
|
||||
* "row" as the given node, or null if there is none.
|
||||
*/
|
||||
getOutNode(node = getFocusManager().getFocusedNode()): IFocusableNode | null {
|
||||
// Special case: blocks and input value connections on blocks with external
|
||||
// inputs should always navigate to the parent block, even though they're
|
||||
// not necessarily on the same visual row.
|
||||
const connection =
|
||||
node instanceof BlockSvg
|
||||
? node.outputConnection?.targetConnection
|
||||
: node instanceof RenderedConnection &&
|
||||
node.type === ConnectionType.INPUT_VALUE
|
||||
? node
|
||||
: null;
|
||||
if (
|
||||
connection &&
|
||||
!connection.getSourceBlock().getInputsInline() &&
|
||||
connection !== connection.getSourceBlock().inputList[0].connection
|
||||
) {
|
||||
return connection.getSourceBlock();
|
||||
}
|
||||
|
||||
return this.getPreviousNodeImpl(node, node, NavigationDirection.OUT);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user