From 9a522fc5ba52f06f0395d644854508a3fe628dee Mon Sep 17 00:00:00 2001 From: Monviech Date: Fri, 30 Jan 2026 08:58:27 +0100 Subject: [PATCH] Firewall: Rules [new]: Remember the last selected interface and restore it inside the selectpicker automatically on load --- .../app/views/OPNsense/Firewall/filter_rule.volt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/opnsense/mvc/app/views/OPNsense/Firewall/filter_rule.volt b/src/opnsense/mvc/app/views/OPNsense/Firewall/filter_rule.volt index f296ea83fd..8d585acd99 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Firewall/filter_rule.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Firewall/filter_rule.volt @@ -66,7 +66,9 @@ // read interface from URL hash once, for the first grid load const hashMatchInterface = window.location.hash.match(/(?:^#|&)interface=([^&]+)/); - let pendingUrlInterface = hashMatchInterface ? decodeURIComponent(hashMatchInterface[1]) : null; + let pendingUrlInterface = hashMatchInterface + ? decodeURIComponent(hashMatchInterface[1]) + : localStorage.getItem('firewall_rule_interface'); // Lives outside the grid, so the logic of the response handler can be changed after grid initialization function dynamicResponseHandler(resp) { @@ -739,12 +741,14 @@ false, function (data) { // post_callback, apply the URL hash logic const match = window.location.hash.match(/^#interface=([^&]+)/); - if (match) { - const ifaceFromHash = decodeURIComponent(match[1]); + const iface = match + ? decodeURIComponent(match[1]) + : localStorage.getItem('firewall_rule_interface'); + if (iface) { const allOptions = Object.values(data).flatMap(group => group.items.map(i => i.value)); - if (allOptions.includes(ifaceFromHash)) { - $('#interface_select').val(ifaceFromHash).selectpicker('refresh'); + if (allOptions.includes(iface)) { + $('#interface_select').val(iface).selectpicker('refresh'); } } interfaceInitialized = true; @@ -763,6 +767,7 @@ if (!interfaceInitialized || reconfigureActInProgress) return; const hashVal = encodeURIComponent($(this).val() ?? ''); + localStorage.setItem('firewall_rule_interface', $(this).val() ?? ''); history.replaceState(null, null, `#interface=${hashVal}`); grid.bootgrid('reload'); });