Skip to content

Commit 8d6f4f7

Browse files
committed
fix search input not focusing by using transition display allow-discrete, which has been supported since 2024 apparently
1 parent cdc9ed7 commit 8d6f4f7

6 files changed

Lines changed: 64 additions & 48 deletions

File tree

all/search/search.css

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.search-modal {
2-
display: block;
3-
visibility: hidden;
42
border: none;
53
padding: 0;
64
position: fixed;
@@ -12,12 +10,10 @@
1210
display: flex;
1311
flex-direction: column;
1412
align-items: center;
15-
background-color: rgba(0, 0, 0, 0.5);
13+
background-color: rgba(0, 0, 0, 0.8);
1614
opacity: 0;
17-
pointer-events: none;
1815
/* Remove text selection on close. Should be fine without though */
19-
user-select: none;
20-
transition: all 0.5s;
16+
transition: opacity 0.5s, display 0.5s allow-discrete;
2117
max-width: unset;
2218
max-height: unset;
2319

@@ -32,10 +28,7 @@
3228
overflow: hidden;
3329
}
3430
.search-modal[open] {
35-
visibility: visible;
3631
opacity: 1;
37-
pointer-events: unset;
38-
user-select: text;
3932
}
4033
.search-modal::backdrop {
4134
background: none;

all/search/start.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import('/all/search/search.js').then(({ loadSearch }) => {
1010
const search = Object.assign(document.createElement('input'), {
1111
className: 'search',
1212
type: 'search',
13+
name: 'q',
1314
placeholder: 'Search everything',
1415
ariaLabel: 'Search everything'
1516
})

home-page/index.html.scss

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,13 +1056,6 @@ html[prefix="og: http://ogp.me/ns/website#"][lang="en"][dir="ltr"]
10561056
z-index: 2;
10571057
grid-area: search;
10581058
}
1059-
.search-button {
1060-
text-align: left;
1061-
transition: box-shadow 0.2s;
1062-
}
1063-
.search-button:hover {
1064-
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.8);
1065-
}
10661059
}
10671060
@media (min-width: 1000px) {
10681061
.search-button-wrapper {
@@ -1071,11 +1064,37 @@ html[prefix="og: http://ogp.me/ns/website#"][lang="en"][dir="ltr"]
10711064
}
10721065
}
10731066
.projects-info.search-button-wrapper {
1067+
css {
1068+
.search-button {
1069+
display: flex;
1070+
align-items: center;
1071+
text-align: left;
1072+
transition: box-shadow 0.2s;
1073+
}
1074+
.search-button:hover {
1075+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.8);
1076+
}
1077+
}
10741078
button.search.search-button#search-button {
10751079
content: 'Search everything';
1080+
1081+
css {
1082+
.search-shortcut {
1083+
margin-left: auto;
1084+
font-family: inherit;
1085+
border: 1px solid rgba(151, 189, 179, 0.2);
1086+
border-radius: 5px;
1087+
width: 20px;
1088+
display: block;
1089+
text-align: center;
1090+
}
1091+
}
1092+
kbd.search-shortcut {
1093+
content: '/';
1094+
}
10761095
}
10771096
}
1078-
dialog.search-modal#search-modal {
1097+
dialog.search-modal#search-modal[inert] {
10791098
form.search-wrapper#search-form[autocomplete='off'][action='/all/search/'] {
10801099
input.search#search[type='search'][name='q'][placeholder='Search everything'][aria-label='Search everything'] {
10811100
}

home-page/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,18 @@ function startSearch () {
214214
loadSearch(search, searchForm, suggestions)
215215
startedSearch = true
216216
}
217+
searchModal.inert = false
217218
searchModal.showModal()
218-
// search.focus()
219219
}
220220
searchButton.addEventListener('click', startSearch)
221221
searchModal.addEventListener('click', e => {
222222
if (e.target === searchModal || e.target === searchForm) {
223223
searchModal.close()
224224
}
225225
})
226+
searchModal.addEventListener('close', () => {
227+
searchModal.inert = true
228+
})
226229
window.addEventListener('keydown', e => {
227230
if (e.target.tagName === 'INPUT') {
228231
return

0 commit comments

Comments
 (0)