Skip to content
Snippets Groups Projects
Commit 4fbe2787 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

app-shell: preserve the "extra" path components when changing the routing state

In case the current language changes or the current activity is re-selected in the
menu we don't want to lose the extra trailing path components.
parent 5546931d
No related branches found
No related tags found
No related merge requests found
Pipeline #192183 passed
...@@ -200,10 +200,10 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -200,10 +200,10 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
}, },
{ {
name: 'mainRoute', name: 'mainRoute',
path: ['/:component', '/:component/(.*)'], path: ['/:component/:extra*'],
action: (context, params) => { action: (context, params) => {
let componentTag = params.component.toLowerCase(); let componentTag = params.component.toLowerCase();
let extra = params[0] ? params[0].split('/') : []; let extra = params.extra ?? [];
return { return {
lang: params.lang, lang: params.lang,
component: componentTag, component: componentTag,
...@@ -958,12 +958,19 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -958,12 +958,19 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
// build the menu // build the menu
let menuTemplates = []; let menuTemplates = [];
for (let routingName of this.visibleRoutes) { for (let routingName of this.visibleRoutes) {
let partialState = {
component: routingName,
};
// clear the extra state for everything but the current activity
if (this.activeView !== routingName) {
partialState['extra'] = [];
}
menuTemplates.push( menuTemplates.push(
html` html`
<li> <li>
<a <a
@click="${(e) => this.onMenuItemClick(e)}" @click="${(e) => this.onMenuItemClick(e)}"
href="${this.router.getPathname({component: routingName})}" href="${this.router.getPathname(partialState)}"
data-nav data-nav
class="${getSelectClasses(routingName)}" class="${getSelectClasses(routingName)}"
title="${this.metaDataText(routingName, 'description')}"> title="${this.metaDataText(routingName, 'description')}">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment