Skip to content

Commit acb038e

Browse files
committed
Use documentElement to override cmd+F
1 parent 19f65ff commit acb038e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/react-devtools-shared/src/devtools/views/SearchInput.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ export default function SearchInput({
6464
const handleKeyDown = (event: KeyboardEvent) => {
6565
const {key, metaKey} = event;
6666
if (key === 'f' && metaKey) {
67-
if (inputRef.current !== null) {
68-
inputRef.current.focus();
67+
const inputElement = inputRef.current;
68+
if (inputElement !== null) {
69+
inputElement.focus();
6970
event.preventDefault();
7071
event.stopPropagation();
7172
}
@@ -75,10 +76,10 @@ export default function SearchInput({
7576
// It's important to listen to the ownerDocument to support the browser extension.
7677
// Here we use portals to render individual tabs (e.g. Profiler),
7778
// and the root document might belong to a different window.
78-
const ownerDocument = inputRef.current.ownerDocument;
79-
ownerDocument.addEventListener('keydown', handleKeyDown);
79+
const ownerDocumentElement = inputRef.current.ownerDocument.documentElement;
80+
ownerDocumentElement.addEventListener('keydown', handleKeyDown);
8081

81-
return () => ownerDocument.removeEventListener('keydown', handleKeyDown);
82+
return () => ownerDocumentElement.removeEventListener('keydown', handleKeyDown);
8283
}, []);
8384

8485
return (

0 commit comments

Comments
 (0)