Skip to content

Commit 5814642

Browse files
committed
test_dashboard: highlight the displayed mock in search results
1 parent 7a3b075 commit 5814642

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

devtools/test_dashboard/devtools.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function searchMocks(e) {
202202

203203
results.forEach(function(r) {
204204
var result = document.createElement('span');
205-
result.className = 'search-result';
205+
result.className = getResultClass(r.name);
206206
result.innerText = r.name;
207207

208208
result.addEventListener('click', function() {
@@ -212,6 +212,10 @@ function searchMocks(e) {
212212
// Clear plots and plot selected.
213213
Tabs.purge();
214214
Tabs.plotMock(mockName);
215+
216+
mocksList.querySelectorAll('span').forEach(function(el) {
217+
el.className = getResultClass(el.innerText);
218+
});
215219
});
216220

217221
mocksList.appendChild(result);
@@ -222,8 +226,16 @@ function searchMocks(e) {
222226
});
223227
}
224228

229+
function getNameFromHash() {
230+
return window.location.hash.replace(/^#/, '');
231+
}
232+
233+
function getResultClass(name) {
234+
return 'search-result' + (getNameFromHash() === name ? ' search-result__selected' : '');
235+
}
236+
225237
function plotFromHash() {
226-
var initialMock = window.location.hash.replace(/^#/, '');
238+
var initialMock = getNameFromHash();
227239

228240
if(initialMock.length > 0) {
229241
Tabs.plotMock(initialMock);

devtools/test_dashboard/style.css

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ header span{
5656
color: #fff;
5757
background-color: #4983EC;
5858
}
59+
.search-result__selected{
60+
background-color: #DDDDEE;
61+
}
5962
#plots{
6063
overflow: scroll;
6164
}

0 commit comments

Comments
 (0)