diff --git a/app/webpacker/controllers/tabs_and_panels_controller.js b/app/webpacker/controllers/tabs_and_panels_controller.js index d3ea9a44fe..050a4fff25 100644 --- a/app/webpacker/controllers/tabs_and_panels_controller.js +++ b/app/webpacker/controllers/tabs_and_panels_controller.js @@ -37,6 +37,16 @@ export default class extends Controller { window.addEventListener("tabs-and-panels:click", (event) => { this.simulateClick(event.detail.tab, event.detail.panel); }); + + window.addEventListener("popstate", (event) => { + const newPanelId = event.target.location.hash.replace("#/", ""); + const currentPanelId = this.currentActivePanel.id; + + if (newPanelId !== currentPanelId) { + const newTabId = newPanelId.split("_panel").shift(); + this.simulateClick(newTabId, newPanelId); + } + }); } simulateClick(tab, panel) { diff --git a/spec/system/admin/enterprises_spec.rb b/spec/system/admin/enterprises_spec.rb index 3e550a0167..1660fc3da2 100644 --- a/spec/system/admin/enterprises_spec.rb +++ b/spec/system/admin/enterprises_spec.rb @@ -119,6 +119,15 @@ describe ' accept_alert do click_link "Primary Details" end + + # Back navigation loads the tab content + page.execute_script('window.history.back()') + expect(page).to have_selector '#enterprise_description' + + accept_alert do + click_link "Primary Details" + end + # Unchecking hides the Properties tab uncheck 'enterprise_is_primary_producer' choose 'None'