Skip to content

Commit b41eecf

Browse files
authored
V16: Document shows blank page when clicking an active link (#19553)
* fix: if no workspace views are found at all, show a not found page * fix: rather than redirecting to the first available tab, which may not always be available on secondary routing, let the router display the first tab on an empty url this mirrors how workspace views are displayed in umb-workspace-editor
1 parent 0a7a922 commit b41eecf

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/views/edit/content-editor.element.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class UmbContentWorkspaceViewEditElement extends UmbLitElement implements
8585

8686
if (this._hasRootGroups) {
8787
routes.push({
88-
path: `root`,
88+
path: 'root',
8989
component: () => import('./content-editor-tab.element.js'),
9090
setup: (component) => {
9191
(component as UmbContentWorkspaceViewEditTabElement).containerId = null;
@@ -108,17 +108,17 @@ export class UmbContentWorkspaceViewEditElement extends UmbLitElement implements
108108

109109
if (routes.length !== 0) {
110110
routes.push({
111+
...routes[0],
112+
unique: routes[0].path,
111113
path: '',
112-
pathMatch: 'full',
113-
redirectTo: routes[0].path,
114-
});
115-
116-
routes.push({
117-
path: `**`,
118-
component: async () => (await import('@umbraco-cms/backoffice/router')).UmbRouteNotFoundElement,
119114
});
120115
}
121116

117+
routes.push({
118+
path: `**`,
119+
component: async () => (await import('@umbraco-cms/backoffice/router')).UmbRouteNotFoundElement,
120+
});
121+
122122
this._routes = routes;
123123
}
124124

@@ -132,18 +132,20 @@ export class UmbContentWorkspaceViewEditElement extends UmbLitElement implements
132132
? html`
133133
<uui-tab
134134
.label=${this.localize.term('general_generic')}
135-
.active=${this._routerPath + '/root' === this._activePath}
135+
.active=${this._routerPath + '/root' === this._activePath ||
136+
this._routerPath + '/' === this._activePath}
136137
.href=${this._routerPath + '/root'}></uui-tab>
137138
`
138139
: ''}
139140
${repeat(
140141
this._tabs,
141142
(tab) => tab.name,
142-
(tab) => {
143+
(tab, index) => {
143144
const path = this._routerPath + '/tab/' + encodeFolderName(tab.name || '');
144145
return html`<uui-tab
145146
.label=${this.localize.string(tab.name ?? '#general_unnamed')}
146-
.active=${path === this._activePath}
147+
.active=${path === this._activePath ||
148+
(!this._hasRootGroups && index === 0 && this._routerPath + '/' === this._activePath)}
147149
.href=${path}></uui-tab>`;
148150
},
149151
)}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ export class UmbWorkspaceEditorElement extends UmbLitElement {
7575

7676
// Duplicate first workspace and use it for the empty path scenario. [NL]
7777
newRoutes.push({ ...newRoutes[0], unique: newRoutes[0].path, path: '' });
78-
79-
newRoutes.push({
80-
path: `**`,
81-
component: async () => (await import('@umbraco-cms/backoffice/router')).UmbRouteNotFoundElement,
82-
});
8378
}
8479

80+
// Add a catch-all route for not found
81+
// This will be the last route, so it will only match if no other routes match or if no workspace views are defined.
82+
newRoutes.push({
83+
path: `**`,
84+
component: async () => (await import('@umbraco-cms/backoffice/router')).UmbRouteNotFoundElement,
85+
});
86+
8587
this._routes = newRoutes;
8688
}
8789

0 commit comments

Comments
 (0)