@salesforcedevs/docs-components 1.30.1-locale-picker → 1.30.1-locale-picker-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.30.1-locale-picker",
3
+ "version": "1.30.1-locale-picker-1",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -51,7 +51,6 @@ export default class RedocReference extends LightningElement {
51
51
  private docPhaseWrapperElement: Element | null = null;
52
52
  private lastSidebarTop = 0;
53
53
  private _languages: OptionWithLink[] = [];
54
- private langValuePath: string = "id";
55
54
 
56
55
  /**
57
56
  * History length captured at mount (pre-Redoc), used by `onBackClick` to
@@ -131,7 +130,6 @@ export default class RedocReference extends LightningElement {
131
130
  this._languages = toJson(value) || [];
132
131
  }
133
132
 
134
- /** Currently selected locale, matched against `langValuePath`. */
135
133
  @api language: string | null = null;
136
134
 
137
135
  get specTitle(): string | null {
@@ -152,11 +150,10 @@ export default class RedocReference extends LightningElement {
152
150
  }
153
151
 
154
152
  /**
155
- * Only for the docs content type and when more than one localized
156
- * spec is available
153
+ * when more than one localized spec is available
157
154
  */
158
155
  get hasLocalePicker(): boolean {
159
- return this.isDocContentType && this.languages.length > 1;
156
+ return this.languages.length > 1;
160
157
  }
161
158
 
162
159
  /**
@@ -199,12 +196,28 @@ export default class RedocReference extends LightningElement {
199
196
  if (referrerUrl.origin !== window.location.origin) {
200
197
  return null;
201
198
  }
199
+ if (this.isLocaleHref(referrerUrl.pathname)) {
200
+ return null;
201
+ }
202
202
  return referrerUrl.href;
203
203
  } catch {
204
204
  return null;
205
205
  }
206
206
  }
207
207
 
208
+ /**
209
+ * switching locale on this same page.
210
+ */
211
+ private isLocaleHref(pathname: string): boolean {
212
+ return this.languages.some((locale) => {
213
+ const href = locale?.link?.href;
214
+ return (
215
+ !!href &&
216
+ new URL(href, window.location.origin).pathname === pathname
217
+ );
218
+ });
219
+ }
220
+
208
221
  /** When origin is provided, pass it to the footer; otherwise use dx-footer's default. */
209
222
  get effectiveFooterOrigin(): string {
210
223
  return (
@@ -443,7 +456,7 @@ export default class RedocReference extends LightningElement {
443
456
  this.appendFooterItems(apiContentDiv);
444
457
 
445
458
  // Inject the multi-spec project header into Redoc's left menu only.
446
- this.insertProjectHeaderInMenu(redocContainer);
459
+ this.insertSidebarNav(redocContainer);
447
460
 
448
461
  // Wait for footer to be rendered before updating styles
449
462
  requestAnimationFrame(() => {
@@ -460,7 +473,7 @@ export default class RedocReference extends LightningElement {
460
473
  /**
461
474
  * Inserts the project header into Redoc for multi-spec reference sets.
462
475
  */
463
- private insertProjectHeaderInMenu(redocContainer: HTMLElement): void {
476
+ private insertSidebarNav(redocContainer: HTMLElement): void {
464
477
  if (!this.showRedocHeader) {
465
478
  return;
466
479
  }
@@ -495,8 +508,7 @@ export default class RedocReference extends LightningElement {
495
508
 
496
509
  Object.assign(picker, {
497
510
  languages: this.languages,
498
- language: this.language,
499
- langValuePath: this.langValuePath
511
+ language: this.language
500
512
  });
501
513
  wrapper.appendChild(picker);
502
514