@@ -98,6 +98,11 @@ export function createWorkspaceFocusController(doc: Document) {
9898 keyboardArea ?. removeAttribute ( "data-workspace-keyboard-focus" ) ;
9999 keyboardArea = undefined ;
100100 } ;
101+ const markKeyboardArea = ( area : HTMLElement ) => {
102+ if ( ! area . matches ( ":focus-visible" ) ) return ;
103+ keyboardArea = area ;
104+ area . setAttribute ( "data-workspace-keyboard-focus" , "" ) ;
105+ } ;
101106 const remember = ( event : FocusEvent ) => {
102107 if ( event . target !== keyboardArea ) unmarkKeyboardArea ( ) ;
103108 // Window activation refocuses the same element; only focus arriving from elsewhere counts.
@@ -106,10 +111,7 @@ export function createWorkspaceFocusController(doc: Document) {
106111 if ( ! ( event . target instanceof HTMLElement ) ) return ;
107112 const area = workspaceArea ( event . target ) ;
108113 if ( ! area ?. dataset . workspaceArea ) return ;
109- if ( arrived && event . target === area && area . matches ( ":focus-visible" ) ) {
110- keyboardArea = area ;
111- area . setAttribute ( "data-workspace-keyboard-focus" , "" ) ;
112- }
114+ if ( arrived && event . target === area ) markKeyboardArea ( area ) ;
113115 lastArea = area . dataset . workspaceArea ;
114116 const key = area . dataset . workspaceFocusKey ?? lastArea ;
115117 lastFocused . delete ( key ) ;
@@ -178,6 +180,8 @@ export function createWorkspaceFocusController(doc: Document) {
178180 const active = root instanceof ShadowRoot ? root . activeElement : doc . activeElement ;
179181 if ( active === target || ( active && target . contains ( active ) ) ) {
180182 if ( target !== area && ! isConversation ) revealInScrollers ( target ) ;
183+ // Focusing the already focused area fires no focusin, as when F6 has nowhere else to go.
184+ if ( target === area ) markKeyboardArea ( area ) ;
181185 return true ;
182186 }
183187 }
0 commit comments