@@ -123,18 +123,19 @@ export function createWorkspaceFocusController(doc: Document) {
123123 } ;
124124 doc . addEventListener ( "focusin" , remember ) ;
125125
126- const focusArea = ( area : HTMLElement , restore = true ) => {
126+ const focusArea = ( area : HTMLElement , restore = true , nested = true ) => {
127127 const key = area . dataset . workspaceFocusKey ?? area . dataset . workspaceArea ! ;
128128 const previous = restore ? lastFocused . get ( key ) : undefined ;
129- const belongs = ( element : HTMLElement ) =>
130- workspaceArea ( element ) === area &&
131- isWorkspaceElementVisible ( element ) &&
132- ! element . matches ( ":disabled" ) ;
129+ const usable = ( element : HTMLElement ) =>
130+ isWorkspaceElementVisible ( element ) && ! element . matches ( ":disabled" ) ;
131+ const belongs = ( element : HTMLElement ) => workspaceArea ( element ) === area && usable ( element ) ;
132+ // A side chat's message input sits in its own area inside the panel. Opening the
133+ // panel focuses it, but F6 visits that area on its own, so it moves past it here.
133134 const preferred = Array . from (
134135 area . querySelectorAll < HTMLElement > (
135136 '[data-workspace-focus-default], [data-sidebar-row][aria-current="page"], [data-settings-section][tabindex="0"], .xterm-helper-textarea, [contenteditable="true"]' ,
136137 ) ,
137- ) . find ( belongs ) ;
138+ ) . find ( nested ? usable : belongs ) ;
138139 const fallback = Array . from ( area . querySelectorAll < HTMLElement > ( FOCUSABLE_SELECTOR ) ) . find (
139140 ( element ) => element . tabIndex >= 0 && belongs ( element ) ,
140141 ) ;
@@ -257,7 +258,7 @@ export function createWorkspaceFocusController(doc: Document) {
257258 : areas . length - 1
258259 : ( current + direction + areas . length ) % areas . length ;
259260 const area = areas [ index ] ! ;
260- return focusArea ( area ) ;
261+ return focusArea ( area , true , false ) ;
261262 } ;
262263
263264 // Focus that drops to the body because its element was hidden, made inert, disabled, or removed
0 commit comments