Skip to content

Commit f8f9d36

Browse files
committed
Remove tab focus while closed
1 parent f64fe61 commit f8f9d36

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "remix-development-tools",
33
"description": "Remix development tools - a set of tools for developing/debugging Remix.run apps",
44
"author": "Alem Tuzlak",
5-
"version": "4.3.2",
5+
"version": "4.3.3",
66
"license": "MIT",
77
"keywords": [
88
"remix",

src/client/RemixDevTools.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from "react";
1+
import { useEffect, useState } from "react";
22
import { RDTContextProvider, RdtClientConfig } from "./context/RDTContext.js";
33
import { Tab } from "./tabs/index.js";
44
import { useTimelineHandler } from "./hooks/useTimelineHandler.js";
@@ -27,6 +27,17 @@ import { useListenToRouteChange } from "./hooks/detached/useListenToRouteChange.
2727
import { RdtPlugin } from "../index.js";
2828
import { 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+
3041
const 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

Comments
 (0)