Skip to content

Commit

Permalink
[Scorecards] When form is submitted user is automatically scroll to t…
Browse files Browse the repository at this point in the history
…he same position
  • Loading branch information
lucascumsille committed Oct 30, 2024
1 parent d8d7036 commit 2b6cd72
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scoring/templates/scoring/includes/advanced-filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,18 @@ <h4 class="fs-8">
selects[j].selectedIndex = 0; // Reset to the first option
}
}

// When the form is submitted, it scrolls you down to the same place you were before submitting it.
var form = document.getElementById('advancedFilterForm');
form.addEventListener('submit', function() {
sessionStorage.setItem('scrollPosition', window.scrollY);
});

window.addEventListener('load', function() {
var scrollPosition = sessionStorage.getItem('scrollPosition');
if (scrollPosition) {
window.scrollTo(0, scrollPosition);
sessionStorage.removeItem('scrollPosition');
}
});
</script>

0 comments on commit 2b6cd72

Please sign in to comment.