@salesforcedevs/docs-components 1.3.345-refactor-tab-alpha4 → 1.3.345-refactor-tab-alpha6

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.3.345-refactor-tab-alpha4",
3
+ "version": "1.3.345-refactor-tab-alpha6",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -386,28 +386,30 @@ export default class ContentLayout extends LightningElement {
386
386
  this._tocOptions = tocOptions;
387
387
  }
388
388
 
389
- onSlotChange(event: Event): void {
390
- const slotElements = (
391
- event.target as HTMLSlotElement
392
- ).assignedElements();
393
-
394
- if (slotElements.length) {
395
- this.contentLoaded = true;
396
- const slotContentElement = slotElements[0];
397
- const headingElements =
398
- slotContentElement.ownerDocument?.getElementsByTagName(
399
- TOC_HEADER_TAG
400
- );
401
-
402
- for (const headingElement of headingElements as any) {
403
- // Sometimes elements hash and header is not being set when slot content is wrapped with div
389
+ setHashAndHeaderForDocHeading(headingElements: any) {
390
+ for (const headingElement of headingElements as any) {
391
+ // Sometimes elements hash and header is not being set when slot content is wrapped with div
392
+ if (!headingElement.hash) {
404
393
  headingElement.hash = headingElement.attributes.hash?.nodeValue;
394
+ }
395
+
396
+ if (!headingElement.header) {
405
397
  headingElement.header =
406
398
  headingElement.attributes.header?.nodeValue;
407
399
  }
408
-
409
- this.updateTocItems(headingElements);
410
400
  }
401
+
402
+ this.updateTocItems(headingElements);
403
+ }
404
+
405
+ updateRNB = () => {
406
+ const headingElements = this.getHeadingElements();
407
+ this.setHashAndHeaderForDocHeading(headingElements);
408
+ };
409
+
410
+ onSlotChange(): void {
411
+ this.updateRNB();
412
+ this.contentLoaded = true;
411
413
  }
412
414
 
413
415
  protected disconnectObserver(): void {
@@ -30,27 +30,12 @@ export default class LwcContentLayout extends ContentLayout {
30
30
  };
31
31
 
32
32
  private getTabPanelList() {
33
+ // eslint-disable-next-line @lwc/lwc/no-document-query
33
34
  return document.querySelector("dx-tab-panel-list");
34
35
  }
35
36
 
36
- updateRNB = () => {
37
- const headingElements = this.getHeadingElements();
38
- headingElements.forEach((headingElement: any) => {
39
- // Sometimes elements hash and header is not being set when slot content is wrapped with div
40
- if (!headingElement.hash) {
41
- headingElement.hash = headingElement.attributes.hash?.nodeValue;
42
- }
43
-
44
- if (!headingElement.header) {
45
- headingElement.header =
46
- headingElement.attributes.header?.nodeValue;
47
- }
48
- });
49
- this.updateTocItems(headingElements);
50
- };
51
-
52
37
  protected getHeadingElements() {
53
- let headingElements = document.querySelectorAll(TOC_HEADER_TAG);
38
+ let headingElements = super.getHeadingElements();
54
39
  if (this.showTabBasedRNB) {
55
40
  const tabPanelListItem: any = this.getTabPanelList();
56
41
  const tabPanels =
@@ -101,6 +86,7 @@ export default class LwcContentLayout extends ContentLayout {
101
86
  };
102
87
 
103
88
  connectedCallback(): void {
89
+ super.connectedCallback();
104
90
  window.addEventListener("popstate", this.handlePopState);
105
91
  }
106
92
 
@@ -173,18 +159,10 @@ export default class LwcContentLayout extends ContentLayout {
173
159
  }
174
160
 
175
161
  updateHeadingForRNB(): void {
176
- // Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
177
- const headingElements = this.getHeadingElements();
178
-
179
162
  // We only need to update URL in case of /docs and ignore if tabs are used anywhere else in DSC
180
163
  if (this.showTabBasedRNB) {
181
164
  this.updateURL();
182
165
  }
183
- this.addObserverAndScroll(headingElements);
184
- }
185
-
186
- onSlotChange(): void {
187
- this.updateRNB();
188
- this.contentLoaded = true;
166
+ super.updateHeadingForRNB();
189
167
  }
190
168
  }