mirror of
https://github.com/google/blockly.git
synced 2026-01-30 12:10:12 +01:00
fix: Focus the first element in flyouts. (#9228)
* fix: Focus the first element in flyouts. * refactor: Adjust retrieval of flyout elements.
This commit is contained in:
@@ -2727,6 +2727,19 @@ export class WorkspaceSvg
|
||||
previousNode: IFocusableNode | null,
|
||||
): IFocusableNode | null {
|
||||
if (!previousNode) {
|
||||
const flyout = this.targetWorkspace?.getFlyout();
|
||||
if (this.isFlyout && flyout) {
|
||||
// Return the first focusable item of the flyout.
|
||||
return (
|
||||
flyout
|
||||
.getContents()
|
||||
.find((flyoutItem) => {
|
||||
const element = flyoutItem.getElement();
|
||||
return isFocusableNode(element) && element.canBeFocused();
|
||||
})
|
||||
?.getElement() ?? null
|
||||
);
|
||||
}
|
||||
return this.getTopBlocks(true)[0] ?? null;
|
||||
} else return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user