Skip to content

fix: Address remaining invisible input positions #8948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions core/keyboard_nav/ast_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ export class ASTNode {
return this.isConnectionLocation;
}

private getVisibleInputs(block: Block): Input[] {
return block.inputList.filter((input) => input.isVisible());
}

/**
* Given an input find the next editable field or an input with a non null
* connection in the same block. The current location must be an input
Expand All @@ -145,9 +149,10 @@ export class ASTNode {
const block = parentInput?.getSourceBlock();
if (!block || !parentInput) return null;

const curIdx = block.inputList.indexOf(parentInput);
for (let i = curIdx + 1; i < block.inputList.length; i++) {
const input = block.inputList[i];
const visibleInputs = this.getVisibleInputs(block);
const curIdx = visibleInputs.indexOf(parentInput);
for (let i = curIdx + 1; i < visibleInputs.length; i++) {
const input = visibleInputs[i];
const fieldRow = input.fieldRow;
for (let j = 0; j < fieldRow.length; j++) {
const field = fieldRow[j];
Expand Down Expand Up @@ -178,10 +183,11 @@ export class ASTNode {
'The current AST location is not associated with a block',
);
}
const curIdx = block.inputList.indexOf(input);
const visibleInputs = this.getVisibleInputs(block);
const curIdx = visibleInputs.indexOf(input);
let fieldIdx = input.fieldRow.indexOf(location) + 1;
for (let i = curIdx; i < block.inputList.length; i++) {
const newInput = block.inputList[i];
for (let i = curIdx; i < visibleInputs.length; i++) {
const newInput = visibleInputs[i];
const fieldRow = newInput.fieldRow;
while (fieldIdx < fieldRow.length) {
if (fieldRow[fieldIdx].isClickable() || ASTNode.NAVIGATE_ALL_FIELDS) {
Expand Down Expand Up @@ -210,9 +216,10 @@ export class ASTNode {
const block = parentInput?.getSourceBlock();
if (!block || !parentInput) return null;

const curIdx = block.inputList.indexOf(parentInput);
const visibleInputs = this.getVisibleInputs(block);
const curIdx = visibleInputs.indexOf(parentInput);
for (let i = curIdx; i >= 0; i--) {
const input = block.inputList[i];
const input = visibleInputs[i];
if (input.connection && input !== parentInput) {
return ASTNode.createInputNode(input);
}
Expand Down Expand Up @@ -242,10 +249,11 @@ export class ASTNode {
'The current AST location is not associated with a block',
);
}
const curIdx = block.inputList.indexOf(parentInput);
const visibleInputs = this.getVisibleInputs(block);
const curIdx = visibleInputs.indexOf(parentInput);
let fieldIdx = parentInput.fieldRow.indexOf(location) - 1;
for (let i = curIdx; i >= 0; i--) {
const input = block.inputList[i];
const input = visibleInputs[i];
if (input.connection && input !== parentInput) {
return ASTNode.createInputNode(input);
}
Expand All @@ -259,7 +267,7 @@ export class ASTNode {
// Reset the fieldIdx to the length of the field row of the previous
// input.
if (i - 1 >= 0) {
fieldIdx = block.inputList[i - 1].fieldRow.length - 1;
fieldIdx = visibleInputs[i - 1].fieldRow.length - 1;
}
}
return null;
Expand Down Expand Up @@ -458,10 +466,9 @@ export class ASTNode {
* block.
*/
private findFirstFieldOrInput(block: Block): ASTNode | null {
const inputs = block.inputList;
for (let i = 0; i < inputs.length; i++) {
const input = inputs[i];
if (!input.isVisible()) continue;
const visibleInputs = this.getVisibleInputs(block);
for (let i = 0; i < visibleInputs.length; i++) {
const input = visibleInputs[i];

const fieldRow = input.fieldRow;
for (let j = 0; j < fieldRow.length; j++) {
Expand Down
Loading