diff --git a/components/fsxa/AppLayout.tsx b/components/fsxa/AppLayout.tsx index b3f5aeb..429d098 100644 --- a/components/fsxa/AppLayout.tsx +++ b/components/fsxa/AppLayout.tsx @@ -93,7 +93,6 @@ class AppLayout extends FSXABaseAppLayout { handleNavigationClick(item: NavigationItem) { if (['language.de', 'language.en'].includes(item.key as string)) { this.triggerRouteChange({ - pageId: this.currentPage?.id, locale: item.key === 'language.de' ? 'de_DE' : 'en_GB' }) } else { diff --git a/docs/modules/ROOT/pages/components/FSXABaseComponent.adoc b/docs/modules/ROOT/pages/components/FSXABaseComponent.adoc index dcebdc7..43e0aca 100644 --- a/docs/modules/ROOT/pages/components/FSXABaseComponent.adoc +++ b/docs/modules/ROOT/pages/components/FSXABaseComponent.adoc @@ -8,7 +8,8 @@ == Introduction The FSXABaseComponent is there to have a basic component to be able to implement further components. -It provides different attributes and methods, which should simplify the development significantly. These are described in this section. +It provides different attributes and methods, which should simplify the development significantly. +These are described in this section. == Usage @@ -52,7 +53,8 @@ Note: If you only want type support for your slots and not the props or events y === `currentPage` - string -This property returns the NavigationItem that is matching the current path. If `null` is returned, no current route could be matched to the current path. +This property returns the NavigationItem that is matching the current path. +If `null` is returned, no current route could be matched to the current path. === `fsxaApi` - Object @@ -60,11 +62,13 @@ This property returns a preconfigured and ready-to-use FSXA-API instance. === `globalSettings` - string -This property returns the globally configured project properties. If no projectProperties are defined in your CaaS this will return `null`. +This property returns the globally configured project properties. +If no projectProperties are defined in your CaaS this will return `null`. === `isEditMode` - boolean -This property returns `true` if the app is delivering preview data. It will return `false` if it is released data. +This property returns `true` if the app is delivering preview data. +It will return `false` if it is released data. === `locale` - string @@ -92,7 +96,8 @@ This method returns the stored data which was set with the given key. getUrlByPageId(pageId: string, locale?: string | undefined): string | null ---- -This method returns the corresponding route for a given `pageId`. If no page was found `null` will be returned. +This method returns the corresponding route for a given `pageId`. +If no page was found `null` will be returned. === `setStoredItem` @@ -113,4 +118,22 @@ You can specify a time-to-live duration in ms, that determines how long the valu triggerRouteChange(params: {pageId?:string, route?:string, locale?:string}): Promise ---- -This method will trigger a route change request. A `pageId`, `route` or `locale` can be passed in. If a corresponding page is found the route change will be triggered. Since this is only available when javascript is enabled, make sure that some kind of fallback is provided. +This method will trigger a route change request. A `pageId`, `route` or `locale` can be passed in. +If a corresponding page is found the route change will be triggered. +Since this is only available when javascript is enabled, make sure that some kind of fallback is provided. + +==== `language switch` + +With the `triggerRouteChange` method you can also implement a language switch. +When implementing this you have to provide a valid locale abbreviation. +Make sure that you *only* pass the locale parameter. +Otherwise, undesirable side effects may occur. + + +Example: +[source, javascript] +---- +triggerRouteChange({locale: 'en_GB'}) +---- + +