mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-19 04:49:15 +00:00
Fix navigation behavior on enterprise panel tabs
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user