Add click-on-same-month to exit drill-down
Clicking on the already-selected month button now returns to root view when drilled down, providing a quick way to reset the chart without using browser back or center click. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d93c7c6051
commit
3e0726d34f
19
app.js
19
app.js
@ -73,6 +73,16 @@ function navigateForward() {
|
||||
}
|
||||
}
|
||||
|
||||
// Go directly to root level
|
||||
function goToRoot() {
|
||||
if (drillDownHistory.length > 0 && historyIndex > 0) {
|
||||
historyIndex = 0;
|
||||
navigateToHistoryState(drillDownHistory[0]);
|
||||
// Update browser history to reflect root state
|
||||
history.replaceState({ drillDown: 0 }, '');
|
||||
}
|
||||
}
|
||||
|
||||
// Listen for browser back/forward via popstate
|
||||
window.addEventListener('popstate', function(e) {
|
||||
// If a modal is open, close it and push state back to prevent navigation
|
||||
@ -1602,9 +1612,16 @@ function navigateToPath(sunburstData, path) {
|
||||
|
||||
// Select and load a specific month
|
||||
async function selectMonth(index) {
|
||||
currentMonthIndex = index;
|
||||
const month = availableMonths[index];
|
||||
|
||||
// If clicking on the already-selected month while drilled down, reset to root
|
||||
if (index === currentMonthIndex && currentDrillPath.length > 0) {
|
||||
goToRoot();
|
||||
return;
|
||||
}
|
||||
|
||||
currentMonthIndex = index;
|
||||
|
||||
// Update hidden select for compatibility
|
||||
const select = document.getElementById('month-select');
|
||||
select.value = month;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user