Skip to content

Commit 1e544f0

Browse files
authored
Merge pull request #765 from plotly/test-dashboard-hash-fragment
Persist the current test dashboard mock on page reload
2 parents fb52c8c + 2d7ed43 commit 1e544f0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

devtools/test_dashboard/devtools.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ var plotArea = document.getElementById('plots');
175175

176176
searchBar.addEventListener('keyup', debounce(searchMocks, 250));
177177

178+
window.onload = function() {
179+
var initialMock = window.location.hash.replace(/^#/, '');
180+
181+
if(initialMock.length > 0) {
182+
Tabs.plotMock(initialMock);
183+
}
184+
};
185+
178186
function debounce(func, wait, immediate) {
179187
var timeout;
180188
return function() {
@@ -206,10 +214,12 @@ function searchMocks(e) {
206214
result.innerText = r.name;
207215

208216
result.addEventListener('click', function() {
217+
var mockName = r.file.slice(0, -5);
218+
window.location.hash = mockName;
209219

210220
// Clear plots and plot selected.
211221
Tabs.purge();
212-
Tabs.plotMock(r.file.slice(0, -5));
222+
Tabs.plotMock(mockName);
213223
});
214224

215225
mocksList.appendChild(result);

0 commit comments

Comments
 (0)