Skip to content

Commit db3374b

Browse files
authored
Docs/Examples/Manual: Keep focus when clear search input. (mrdoob#25194)
* chore: re-focus filter input when clicking the X * chore: renaming the exitSearchButton to clearSearchButton * fix: re-focus also in examples and manual
1 parent e7257e2 commit db3374b

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

docs/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
2929
<div id="contentWrapper">
3030
<div id="inputWrapper">
3131
<input placeholder="" type="text" id="filterInput" autocorrect="off" autocapitalize="off" spellcheck="false" />
32-
<div id="exitSearchButton"></div>
32+
<div id="clearSearchButton"></div>
3333
<select id="language">
3434
<option value="en">en</option>
3535
<option value="ar">ar</option>
@@ -54,7 +54,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
5454
const panel = document.getElementById( 'panel' );
5555
const content = document.getElementById( 'content' );
5656
const expandButton = document.getElementById( 'expandButton' );
57-
const exitSearchButton = document.getElementById( 'exitSearchButton' );
57+
const clearSearchButton = document.getElementById( 'clearSearchButton' );
5858
const panelScrim = document.getElementById( 'panelScrim' );
5959
const filterInput = document.getElementById( 'filterInput' );
6060
let iframe = document.querySelector( 'iframe' );
@@ -165,11 +165,11 @@ <h1><a href="https://threejs.org">three.js</a></h1>
165165

166166
};
167167

168-
exitSearchButton.onclick = function () {
168+
clearSearchButton.onclick = function () {
169169

170170
filterInput.value = '';
171171
updateFilter();
172-
panel.classList.remove( 'searchFocused' );
172+
filterInput.focus();
173173

174174
};
175175

examples/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
2929

3030
<div id="inputWrapper">
3131
<input placeholder="" type="text" id="filterInput" autocorrect="off" autocapitalize="off" spellcheck="false" />
32-
<div id="exitSearchButton"></div>
32+
<div id="clearSearchButton"></div>
3333
</div>
3434

3535
<div id="content">
@@ -49,7 +49,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
4949
const content = document.getElementById( 'content' );
5050
const viewer = document.getElementById( 'viewer' );
5151
const filterInput = document.getElementById( 'filterInput' );
52-
const exitSearchButton = document.getElementById( 'exitSearchButton' );
52+
const clearSearchButton = document.getElementById( 'clearSearchButton' );
5353
const expandButton = document.getElementById( 'expandButton' );
5454
const viewSrcButton = document.getElementById( 'button' );
5555
const panelScrim = document.getElementById( 'panelScrim' );
@@ -153,11 +153,11 @@ <h1><a href="https://threejs.org">three.js</a></h1>
153153

154154
};
155155

156-
exitSearchButton.onclick = function ( ) {
156+
clearSearchButton.onclick = function ( ) {
157157

158158
filterInput.value = '';
159159
updateFilter( files, tags );
160-
panel.classList.remove( 'searchFocused' );
160+
filterInput.focus();
161161

162162
};
163163

files/main.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ h1 a {
138138
transition: 0s 0s height;
139139
}
140140

141-
#panel #exitSearchButton {
141+
#panel #clearSearchButton {
142142
width: 48px;
143143
height: 48px;
144144
display: none;
@@ -154,7 +154,7 @@ h1 a {
154154
margin-right: 0px;
155155
}
156156

157-
#panel.searchFocused #exitSearchButton {
157+
#panel.searchFocused #clearSearchButton {
158158
display: block;
159159
}
160160

manual/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
2828
<div id="contentWrapper">
2929
<div id="inputWrapper">
3030
<input placeholder="" type="text" id="filterInput" autocorrect="off" autocapitalize="off" spellcheck="false" />
31-
<div id="exitSearchButton"></div>
31+
<div id="clearSearchButton"></div>
3232
<select id="language">
3333
<option value="en">en</option>
3434
<option value="fr">fr</option>
@@ -51,7 +51,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
5151
const panel = document.querySelector( '#panel' );
5252
const content = document.querySelector( '#content' );
5353
const expandButton = document.querySelector( '#expandButton' );
54-
const exitSearchButton = document.querySelector( '#exitSearchButton' );
54+
const clearSearchButton = document.querySelector( '#clearSearchButton' );
5555
const panelScrim = document.querySelector( '#panelScrim' );
5656
const filterInput = document.querySelector( '#filterInput' );
5757
let iframe = document.querySelector( 'iframe' );
@@ -141,11 +141,11 @@ <h1><a href="https://threejs.org">three.js</a></h1>
141141

142142
};
143143

144-
exitSearchButton.onclick = function () {
144+
clearSearchButton.onclick = function () {
145145

146146
filterInput.value = '';
147147
updateFilter();
148-
panel.classList.remove( 'searchFocused' );
148+
filterInput.focus();
149149

150150
};
151151

0 commit comments

Comments
 (0)