Skip to content

Commit e2b6072

Browse files
committed
Remove tab logic (these will be full page loads)
1 parent 6cce46f commit e2b6072

File tree

2 files changed

+10
-38
lines changed

2 files changed

+10
-38
lines changed

app/assets/stylesheets/partials/_loading_spinner.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// Loading indicator for Turbo Frame updates
1+
// Loading indicator for pagination (Turbo Frame updates)
2+
// Tab navigation uses full page loads with Turbo's built-in progress bar
23
// https://discuss.hotwired.dev/t/show-spinner-everytime-async-frame-reloads/3483/3
34
@keyframes spinner {
45
to {
56
transform: rotate(360deg);
67
}
78
}
89

9-
// Results overlay when loading
10+
// Pagination overlay when loading
1011
[busy]:not([no-spinner]) {
1112
position: relative;
1213
min-height: 400px;

app/javascript/loading_spinner.js

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,10 @@
1-
// Loading spinner behavior for search results
1+
// Loading spinner behavior for pagination (Turbo Frame updates)
22
document.addEventListener('turbo:frame-render', function(event) {
3-
// Remove loading state from tabs when frame finishes loading
4-
const tabs = document.querySelector('.tab-navigation');
5-
if (tabs) {
6-
tabs.classList.remove('loading');
7-
}
8-
9-
// Focus management after content loads
10-
if (window.pendingFocusAction) {
11-
if (window.pendingFocusAction === 'pagination') {
12-
// Focus on first result for pagination
13-
const firstResult = document.querySelector('.results-list .result h3 a, .results-list .result .record-title a');
14-
if (firstResult) {
15-
firstResult.focus();
16-
}
17-
} else if (window.pendingFocusAction === 'tab-switch') {
18-
// Focus on results summary for tab switches
19-
const resultsContext = document.querySelector('.results-context');
20-
if (resultsContext) {
21-
resultsContext.setAttribute('tabindex', '-1');
22-
resultsContext.focus();
23-
}
3+
if (window.pendingFocusAction === 'pagination') {
4+
// Focus on first result for pagination
5+
const firstResult = document.querySelector('.results-list .result h3 a, .results-list .result .record-title a');
6+
if (firstResult) {
7+
firstResult.focus();
248
}
259
// Clear the pending action
2610
window.pendingFocusAction = null;
@@ -30,22 +14,9 @@ document.addEventListener('turbo:frame-render', function(event) {
3014
document.addEventListener('click', function(event) {
3115
const clickedElement = event.target;
3216

33-
// Handle pagination clicks (scroll to top and set pending focus action)
34-
if (clickedElement.matches('.tab-link')) {
35-
const tabs = document.querySelector('.tab-navigation');
36-
if (tabs) {
37-
tabs.classList.add('loading');
38-
}
39-
window.pendingFocusAction = 'tab-switch';
40-
}
41-
42-
// Handle pagination clicks (scroll to top and set pending focus action)
17+
// Handle pagination clicks
4318
if (clickedElement.closest('.pagination-container') ||
4419
clickedElement.matches('.first a, .previous a, .next a')) {
45-
const tabs = document.querySelector('.tab-navigation');
46-
if (tabs) {
47-
tabs.classList.add('loading');
48-
}
4920
window.scrollTo({ top: 0, behavior: 'smooth' });
5021
window.pendingFocusAction = 'pagination';
5122
}

0 commit comments

Comments
 (0)