Skip to content

Commit 806f10e

Browse files
authored
V15/bugfix/fix route issue from 18859 (#18931)
* unique check * unique for workspace empty path * more unique routes
1 parent 788e5cd commit 806f10e

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

src/Umbraco.Web.UI.Client/src/external/router-slot/model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ export interface IRouteBase<D = any> {
6262
// - If "full" router-slot will try to match the entire path.
6363
// - If "fuzzy" router-slot will try to match an arbitrary part of the path.
6464
pathMatch?: PathMatch;
65+
66+
// A unique identifier for the route, used to identify the route so we can avoid re-rendering it.
67+
unique?: string | Symbol;
6568
}
6669

6770
/**

src/Umbraco.Web.UI.Client/src/external/router-slot/router-slot.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,8 @@ export class RouterSlot<D = any, P = any> extends HTMLElement implements IRouter
208208
// If navigate is not determined, then we will check if we have a route match, and if the new match is different from current. [NL]
209209
const newMatch = this.getRouteMatch();
210210
if (newMatch) {
211-
if (this._routeMatch?.route.path !== newMatch.route.path) {
212-
// Check if this match matches the current match (aka. If the path has changed), if so we should navigate. [NL]
213-
navigate = shouldNavigate(this.match, newMatch);
214-
}
211+
// Check if this match matches the current match (aka. If the path has changed), if so we should navigate. [NL]
212+
navigate = shouldNavigate(this.match, newMatch);
215213
}
216214
}
217215
}

src/Umbraco.Web.UI.Client/src/external/router-slot/util/router.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,10 @@ export function shouldNavigate<D>(currentMatch: IRouteMatch<D> | null, newMatch:
301301
const { route: currentRoute, fragments: currentFragments } = currentMatch;
302302
const { route: newRoute, fragments: newFragments } = newMatch;
303303

304-
const isSameRoute = currentRoute == newRoute;
304+
const isSameRoute = currentRoute.path == newRoute.path;
305305
const isSameFragments = currentFragments.consumed == newFragments.consumed;
306+
const isSameBasedOnUnique = currentRoute.unique === newRoute.unique;
306307

307308
// Only navigate if the URL consumption is new or if the two routes are no longer the same.
308-
return !isSameFragments || !isSameRoute;
309+
return !isSameFragments || !isSameRoute || !isSameBasedOnUnique;
309310
}

src/Umbraco.Web.UI.Client/src/packages/core/collection/collection-view.manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export class UmbCollectionViewManager extends UmbControllerBase {
9494

9595
if (routes.length > 0) {
9696
routes.push({
97+
unique: fallbackView.alias,
9798
path: '',
9899
component: () => createExtensionElement(fallbackView),
99100
setup: () => {

src/Umbraco.Web.UI.Client/src/packages/core/modal/component/modal.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export class UmbModalElement extends UmbLitElement {
9595
this.#modalRouterElement = document.createElement('umb-router-slot');
9696
this.#modalRouterElement.routes = [
9797
{
98+
unique: '_umbEmptyRoute_',
9899
path: '',
99100
component: document.createElement('slot'),
100101
},

src/Umbraco.Web.UI.Client/src/packages/core/router/components/router-slot/route.context.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class UmbRouteContext extends UmbContextBase<UmbRouteContext> {
6060
#generateRoute(modalRegistration: UmbModalRouteRegistration): UmbRoutePlusModalKey {
6161
return {
6262
__modalKey: modalRegistration.key,
63+
unique: 'umbModalKey_' + modalRegistration.key,
6364
path: '/' + modalRegistration.generateModalPath(),
6465
component: EmptyDiv,
6566
setup: async (component, info) => {
@@ -112,6 +113,7 @@ export class UmbRouteContext extends UmbContextBase<UmbRouteContext> {
112113
// Add an empty route, so there is a route for the router to react on when no modals are open.
113114
this.#modalRoutes.push({
114115
__modalKey: '_empty_',
116+
unique: 'umbEmptyModal',
115117
path: '',
116118
component: EmptyDiv,
117119
});

src/Umbraco.Web.UI.Client/src/packages/core/workspace/components/workspace-editor/workspace-editor.element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ export class UmbWorkspaceEditorElement extends UmbLitElement {
7070
(component as any).manifest = manifest;
7171
}
7272
},
73-
} as UmbRoute;
73+
};
7474
});
7575

7676
// Duplicate first workspace and use it for the empty path scenario. [NL]
77-
newRoutes.push({ ...newRoutes[0], path: '' });
77+
newRoutes.push({ ...newRoutes[0], unique: newRoutes[0].path, path: '' });
7878

7979
newRoutes.push({
8080
path: `**`,

0 commit comments

Comments
 (0)