Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3f27d34

Browse files
committed
Allow / to be entered into search box, don't focus if edit already focused
1 parent23f0b42 commit3f27d34

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1+
functionisInputFocused(){
2+
constactiveElement=document.activeElement;
3+
return(
4+
activeElement.tagName==='INPUT'||
5+
activeElement.tagName==='TEXTAREA'||
6+
activeElement.isContentEditable
7+
);
8+
}
9+
110
document.addEventListener('keydown',function(event){
211
if(event.key==='/'){
3-
// Prevent "/" from being entered in the search box
4-
event.preventDefault();
12+
if(!isInputFocused()){
13+
// Prevent "/" from being entered in the search box
14+
event.preventDefault();
515

6-
// Set the focus on the search box
7-
letsearchBox=document.getElementById('search-box');
8-
searchBox.focus();
16+
// Set the focus on the search box
17+
constsearchBox=document.getElementById('search-box');
18+
searchBox.focus();
19+
}
920
}
1021
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp