Skip to content

Commit 7a7fad4

Browse files
authored
fix: Reenable support for tabbing between fields. (#9049)
* fix: Reenable support for tabbing between fields. * refactor: Reduce code duplication.
1 parent e117980 commit 7a7fad4

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

core/field_input.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
FieldValidator,
2828
UnattachedFieldError,
2929
} from './field.js';
30+
import type {IFocusableNode} from './interfaces/i_focusable_node.js';
3031
import {Msg} from './msg.js';
3132
import * as renderManagement from './render_management.js';
3233
import * as aria from './utils/aria.js';
@@ -582,6 +583,28 @@ export abstract class FieldInput<T extends InputTypes> extends Field<
582583
);
583584
WidgetDiv.hideIfOwner(this);
584585
dropDownDiv.hideWithoutAnimation();
586+
} else if (e.key === 'Tab') {
587+
e.preventDefault();
588+
const cursor = this.workspace_?.getCursor();
589+
590+
const isValidDestination = (node: IFocusableNode | null) =>
591+
(node instanceof FieldInput ||
592+
(node instanceof BlockSvg && node.isSimpleReporter())) &&
593+
node !== this.getSourceBlock();
594+
595+
let target = e.shiftKey
596+
? cursor?.getPreviousNode(this, isValidDestination, false)
597+
: cursor?.getNextNode(this, isValidDestination, false);
598+
target =
599+
target instanceof BlockSvg && target.isSimpleReporter()
600+
? target.getFields().next().value
601+
: target;
602+
603+
if (target instanceof FieldInput) {
604+
WidgetDiv.hideIfOwner(this);
605+
dropDownDiv.hideWithoutAnimation();
606+
target.showEditor();
607+
}
585608
}
586609
}
587610

0 commit comments

Comments
 (0)