Skip to content
Draft
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions core/flyout_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import {FlyoutMetricsManager} from './flyout_metrics_manager.js';
import {FlyoutNavigator} from './flyout_navigator.js';
import {FlyoutSeparator, SeparatorAxis} from './flyout_separator.js';
import { getFocusManager } from './focus_manager.js';

Check failure on line 25 in core/flyout_base.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `·getFocusManager·` with `getFocusManager`
import {IAutoHideable} from './interfaces/i_autohideable.js';
import type {IFlyout} from './interfaces/i_flyout.js';
import type {IFlyoutInflater} from './interfaces/i_flyout_inflater.js';
Expand Down Expand Up @@ -615,6 +616,10 @@
* toolbox definition, or a string with the name of the dynamic category.
*/
show(flyoutDef: toolbox.FlyoutDefinition | string) {
const previouslyFocusedNode = getFocusManager().getFocusedNode();
const hadFocusedItem =

Check failure on line 620 in core/flyout_base.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎·····`
this.getContents().some(
(item) => item.getElement() === previouslyFocusedNode);

Check failure on line 622 in core/flyout_base.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `········(item)·=>·item.getElement()·===·previouslyFocusedNode` with `······(item)·=>·item.getElement()·===·previouslyFocusedNode,⏎····`
this.workspace_.setResizesEnabled(false);
this.hide();
this.clearOldBlocks();
Expand Down Expand Up @@ -655,6 +660,14 @@
}
};
this.workspace_.addChangeListener(this.reflowWrapper);

// It's difficult to restore the actual element that was focused since
// everything gets recreated (and it may no longer exist). Instead, if the
// flyout previously held focus then force it to focus the first element.
const contents = this.getContents();
if (hadFocusedItem && contents.length > 0) {
getFocusManager().focusNode(contents[0].getElement());
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions core/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import type {Block} from './block.js';
import {Blocks} from './blocks.js';
import * as dialog from './dialog.js';
import { getFocusManager } from './focus_manager.js';

Check failure on line 12 in core/variables.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `·getFocusManager·` with `getFocusManager`
import {isLegacyProcedureDefBlock} from './interfaces/i_legacy_procedure_blocks.js';
import {isVariableBackedParameterModel} from './interfaces/i_variable_backed_parameter_model.js';
import {IVariableModel, IVariableState} from './interfaces/i_variable_model.js';
Expand Down Expand Up @@ -519,6 +520,8 @@
defaultText: string,
callback: (p1: string | null) => void,
) {
const returnEphemeralFocus =

Check failure on line 523 in core/variables.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎····getFocusManager().takeEphemeralFocus(document.body` with `·getFocusManager().takeEphemeralFocus(⏎····document.body,⏎··`
getFocusManager().takeEphemeralFocus(document.body);
dialog.prompt(promptText, defaultText, function (newVar) {
// Merge runs of whitespace. Strip leading and trailing whitespace.
// Beyond this, all names are legal.
Expand All @@ -529,6 +532,7 @@
newVar = null;
}
}
returnEphemeralFocus();
callback(newVar);
});
}
Expand Down
5 changes: 3 additions & 2 deletions core/workspace_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import {Gesture} from './gesture.js';
import {Grid} from './grid.js';
import {MutatorIcon} from './icons/mutator_icon.js';
import {isAutoHideable} from './interfaces/i_autohideable.js';

Check failure on line 46 in core/workspace_svg.ts

View workflow job for this annotation

GitHub Actions / lint

'isAutoHideable' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 46 in core/workspace_svg.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `{isAutoHideable}·from·'./interfaces/i_autohideable.js';⏎import·`
import type {IBoundedElement} from './interfaces/i_bounded_element.js';
import {IContextMenu} from './interfaces/i_contextmenu.js';
import type {IDragTarget} from './interfaces/i_drag_target.js';
Expand Down Expand Up @@ -2856,11 +2856,12 @@
// Only hide the flyout if the flyout's workspace is losing focus and that
// focus isn't returning to the flyout itself, the toolbox, or ephemeral.
if (getFocusManager().ephemeralFocusTaken()) return;
const flyout = this.targetWorkspace.getFlyout();

Check failure on line 2859 in core/workspace_svg.ts

View workflow job for this annotation

GitHub Actions / lint

'flyout' is assigned a value but never used. Allowed unused vars must match /^_/u
const toolbox = this.targetWorkspace.getToolbox();
if (toolbox && nextTree === toolbox) return;
if (toolbox) toolbox.clearSelection();
if (flyout && isAutoHideable(flyout)) flyout.autoHide(false);
// TODO: Figure out how to fix this.
// if (toolbox) toolbox.clearSelection();
// if (flyout && isAutoHideable(flyout)) flyout.autoHide(false);
}
}

Expand Down
Loading