summaryrefslogtreecommitdiff
path: root/web/templates
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-13 13:33:43 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-13 13:33:43 -1000
commit2fb1ed729fbd61d70b38a11903fb35eabb2bdca1 (patch)
tree7e251ede777c29c83b1091cade0bb46679660ca0 /web/templates
parentcb9577d586d9cb324b042a0c05d97d231f9c2e75 (diff)
Fix tab state persistence with URL query parameters (Bug 002)
- Extract tab query param in HandleDashboard, default to "tasks" - Wrap DashboardData with ActiveTab field for template access - Update index.html with conditional tab-button-active class - Add hx-push-url="?tab=..." to each tab button for URL persistence - Update content div to load active tab from server state - Update app.js to read currentTab from URL query parameters - Add comprehensive tab_state_test.go test suite - Tab selection now persists through page reloads - All tests passing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'web/templates')
-rw-r--r--web/templates/index.html18
1 files changed, 9 insertions, 9 deletions
diff --git a/web/templates/index.html b/web/templates/index.html
index b545a6e..a1210d6 100644
--- a/web/templates/index.html
+++ b/web/templates/index.html
@@ -26,34 +26,34 @@
<div class="border-b border-gray-200 mb-8 no-print">
<nav class="-mb-px flex space-x-8">
<button
- class="tab-button tab-button-active"
+ class="tab-button {{if eq .ActiveTab "tasks"}}tab-button-active{{end}}"
hx-get="/tabs/tasks"
hx-target="#tab-content"
- hx-push-url="false"
+ hx-push-url="?tab=tasks"
onclick="setActiveTab(this)">
✓ Tasks
</button>
<button
- class="tab-button"
+ class="tab-button {{if eq .ActiveTab "planning"}}tab-button-active{{end}}"
hx-get="/tabs/planning"
hx-target="#tab-content"
- hx-push-url="false"
+ hx-push-url="?tab=planning"
onclick="setActiveTab(this)">
📋 Planning
</button>
<button
- class="tab-button"
+ class="tab-button {{if eq .ActiveTab "notes"}}tab-button-active{{end}}"
hx-get="/tabs/notes"
hx-target="#tab-content"
- hx-push-url="false"
+ hx-push-url="?tab=notes"
onclick="setActiveTab(this)">
📝 Notes
</button>
<button
- class="tab-button"
+ class="tab-button {{if eq .ActiveTab "meals"}}tab-button-active{{end}}"
hx-get="/tabs/meals"
hx-target="#tab-content"
- hx-push-url="false"
+ hx-push-url="?tab=meals"
onclick="setActiveTab(this)">
🍽️ Meals
</button>
@@ -62,7 +62,7 @@
<!-- Tab Content -->
<div id="tab-content"
- hx-get="/tabs/tasks"
+ hx-get="/tabs/{{.ActiveTab}}"
hx-trigger="load"
hx-swap="innerHTML">
<div class="text-center py-8">