8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 23f0b42 commit 3f27d34Copy full SHA for 3f27d34
python_docs_theme/static/search-focus.js
@@ -1,10 +1,21 @@
1
+function isInputFocused() {
2
+ const activeElement = document.activeElement;
3
+ return (
4
+ activeElement.tagName === 'INPUT' ||
5
+ activeElement.tagName === 'TEXTAREA' ||
6
+ activeElement.isContentEditable
7
+ );
8
+}
9
+
10
document.addEventListener('keydown', function(event) {
11
if (event.key === '/') {
- // Prevent "/" from being entered in the search box
- event.preventDefault();
12
+ if (!isInputFocused()) {
13
+ // Prevent "/" from being entered in the search box
14
+ event.preventDefault();
15
- // Set the focus on the search box
- let searchBox = document.getElementById('search-box');
- searchBox.focus();
16
+ // Set the focus on the search box
17
+ const searchBox = document.getElementById('search-box');
18
+ searchBox.focus();
19
+ }
20
}
21
});
0 commit comments