1- import { useState } from "react" ;
1+ import { useEffect , useState } from "react" ;
22import { RDTContextProvider , RdtClientConfig } from "./context/RDTContext.js" ;
33import { Tab } from "./tabs/index.js" ;
44import { useTimelineHandler } from "./hooks/useTimelineHandler.js" ;
@@ -27,6 +27,17 @@ import { useListenToRouteChange } from "./hooks/detached/useListenToRouteChange.
2727import { RdtPlugin } from "../index.js" ;
2828import { useHotkeys } from "react-hotkeys-hook" ;
2929
30+ const recursivelyChangeTabIndex = ( node : Element | HTMLElement , remove = true ) => {
31+ if ( remove ) {
32+ node . setAttribute ( "tabIndex" , "-1" ) ;
33+ } else {
34+ node . removeAttribute ( "tabIndex" ) ;
35+ }
36+ for ( const child of node . children ) {
37+ recursivelyChangeTabIndex ( child , remove ) ;
38+ }
39+ } ;
40+
3041const DevTools = ( { plugins : pluginArray } : RemixDevToolsProps ) => {
3142 useTimelineHandler ( ) ;
3243 useResetDetachmentCheck ( ) ;
@@ -50,7 +61,11 @@ const DevTools = ({ plugins: pluginArray }: RemixDevToolsProps) => {
5061 useHotkeys ( settings . openHotkey , ( ) => debounceSetOpen ( ) ) ;
5162 useHotkeys ( "esc" , ( ) => isOpen ? debounceSetOpen ( ) : null ) ;
5263
53-
64+ useEffect ( ( ) => {
65+ const el = document . getElementById ( REMIX_DEV_TOOLS ) ;
66+ if ( ! el ) return ;
67+ recursivelyChangeTabIndex ( el , ! isOpen ) ;
68+ } , [ isOpen ] )
5469
5570 if ( settings . requireUrlFlag && ! url . includes ( settings . urlFlag ) ) return null ;
5671 // If the dev tools are detached, we don't want to render the main panel
0 commit comments