Skip to content

Commit 2001287

Browse files
Move spinner control to our javascript
1 parent e69f1fd commit 2001287

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app/assets/stylesheets/partials/_loading_spinner.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99

1010
// Pagination overlay when loading
11-
[busy]:not([no-spinner]) {
11+
.spinner {
1212
position: relative;
1313
min-height: 400px;
1414
display: block;

app/javascript/loading_spinner.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ document.addEventListener('turbo:frame-render', function(event) {
3535
currentTabLink.classList.add('active');
3636
currentTabLink.setAttribute('aria-current', 'page');
3737
}
38+
// Remove the spinner now that things are ready
39+
document.getElementById('search-results').classList.remove('spinner');
3840

3941
// Clear the pending action
4042
window.pendingFocusAction = null;
@@ -53,6 +55,10 @@ document.addEventListener('click', function(event) {
5355

5456
// Handle tab clicks
5557
if (clickedElement.closest('.tab-navigation')) {
58+
// Throw the spinner on the search results immediately
59+
document.getElementById('search-results').classList.add('spinner');
60+
61+
// Position the window at the top of the results
5662
window.scrollTo({ top: 0, behavior: 'smooth' });
5763
window.pendingFocusAction = 'tab';
5864
}

0 commit comments

Comments
 (0)