Fix navigation behavior on enterprise panel tabs

This commit is contained in:
Ryan Murphy
2023-11-04 16:08:55 -04:00
parent 5d76f98fec
commit 5c4b06730b
2 changed files with 19 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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'