File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -320,21 +320,28 @@ export function defineBlocks(blocks: {[key: string]: BlockDefinition}) {
320320 * @param e Key down event.
321321 */
322322export function globalShortcutHandler ( e : KeyboardEvent ) {
323- const mainWorkspace = getMainWorkspace ( ) as WorkspaceSvg ;
324- if ( ! mainWorkspace ) {
325- return ;
323+ // This would ideally just be a `focusedTree instanceof WorkspaceSvg`, but
324+ // importing `WorkspaceSvg` (as opposed to just its type) causes cycles.
325+ let workspace : WorkspaceSvg = getMainWorkspace ( ) as WorkspaceSvg ;
326+ const focusedTree = getFocusManager ( ) . getFocusedTree ( ) ;
327+ for ( const ws of getAllWorkspaces ( ) ) {
328+ if ( focusedTree === ( ws as WorkspaceSvg ) ) {
329+ workspace = ws as WorkspaceSvg ;
330+ break ;
331+ }
326332 }
327333
328334 if (
329335 browserEvents . isTargetInput ( e ) ||
330- ( mainWorkspace . rendered && ! mainWorkspace . isVisible ( ) )
336+ ! workspace ||
337+ ( workspace . rendered && ! workspace . isFlyout && ! workspace . isVisible ( ) )
331338 ) {
332339 // When focused on an HTML text input widget, don't trap any keys.
333340 // Ignore keypresses on rendered workspaces that have been explicitly
334341 // hidden.
335342 return ;
336343 }
337- ShortcutRegistry . registry . onKeyDown ( mainWorkspace , e ) ;
344+ ShortcutRegistry . registry . onKeyDown ( workspace , e ) ;
338345}
339346
340347export const TEST_ONLY = { defineBlocksWithJsonArrayInternal} ;
You can’t perform that action at this time.
0 commit comments