From 9b46418d4385f2f89ab6d6afdece13cf910ca86c Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 5 Feb 2026 11:26:42 +0000 Subject: [PATCH] [Scorecards] Added fix for filter where the url has a type of council argument Currently, in a single section page where we display a message advising users the Combined Authorities don't have this section, the link "Show all Combined Authority sections" takes them to `/sections/?type=combined` however this URL does not activate the filter in the sections page to display only the CA. This commit takes in account the arguments in the URL, so the right option is chosen when loading the page --- scoring/static/scoring/js/main.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scoring/static/scoring/js/main.js b/scoring/static/scoring/js/main.js index e62dd1983..1a7deffe1 100644 --- a/scoring/static/scoring/js/main.js +++ b/scoring/static/scoring/js/main.js @@ -432,6 +432,20 @@ forEachElement('[data-methodology-switch-council-type]', function(trigger){ }); }); +// Trigger council type filter from URL parameter +// Example: /sections/?type=combined would make the filter above to select "Combined Authorities" +(function(){ + var urlParams = new URLSearchParams(window.location.search); + var typeParam = urlParams.get('type'); + + if (typeParam) { + var trigger = document.querySelector('[data-methodology-switch-council-type="' + typeParam + '"]'); + if (trigger) { + trigger.click(); + } + } +})(); + // Previous year comparison toggle on council page forEachElement('#js-toggle-previous-year-score', function(el) { el.addEventListener('change', function() {