I'm creating a backoffice section, and it works, but I can't get the section web component to refresh with new querystring values when the url changes (ex. clicking a menu link). https://dev.to/yinzy00/adding-dynamic-routes-and-views-to-custom-umbraco-14-sections-3dcm
I'm not sure how to do this.
Do I need to specify the querystrings in the router entry somehow?
currently:
{
//Section & Tree root
path: 'fulfillment',
preserveQuery: true,
component: () => import('./sectionViews/fulfillmentSection'),
},
url is like
/umbraco/section/management/view/manage/fulfillment/?startDate=2025-01-14&endDate=2025-01-14
and
/umbraco/section/management/view/manage/fulfillment/?startDate=2025-01-13&endDate=2025-01-13
Aaron Sawyer
01/08/2025, 3:59 PM
I figured out how to fix this in my case - I added a pushstate listener to my section web component. ex:
async connectedCallback() {
super.connectedCallback();
await this.updateComplete;
//after render logic goes here
this.init();
//add listener so backoffice clicks fire a search
var self = this;
window.addEventListener('pushstate', function (event) {
if (history.state === null \|\| typeof history.state.internalSearchRunning === 'undefined' || history.state.internalSearchRunning !== true) {
//console.log("extenal url search fired");
self.searchLoading = true;
self.init();
}
});
}