From 9067fc46ea6c2939f6bd11f4e5c909aade93ae03 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Pasquier <contact@jbpasquier.eu> Date: Thu, 7 Mar 2024 00:20:44 +0100 Subject: [PATCH] fix: https://github.com/openfoodfoundation/openfoodnetwork/issues/12243 --- src/components/partials/redirector.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/partials/redirector.js b/src/components/partials/redirector.js index 8812089..62af5a5 100644 --- a/src/components/partials/redirector.js +++ b/src/components/partials/redirector.js @@ -26,15 +26,28 @@ importCore().then(core => { args: () => [this.dataSrc] }) + firstUpdated() { + document.addEventListener('navigate', (e) => { + console.log(e); + if(e.detail.route == `${this.uniq}-products-redirector` && e.explicitOriginalTarget == document.querySelector(`[default-route="${this.uniq}-producers-list"]`)) { + window.dispatchEvent( + new CustomEvent('requestNavigation', { + detail: { + route: `${this.uniq}-products-list` + } + }), + ); + } + }); + } + render() { if(!this.dataSrc || !this.uniq) return nothing; - return this._getResource.render({ pending: () => html`<div class="progress"><div class="indeterminate"></div></div>`, complete: (resource) => { if(resource) { - console.log(resource); window.dispatchEvent( new CustomEvent('requestNavigation', { detail: { -- GitLab