@salesforcedevs/docs-components 1.3.108 → 1.3.110

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.108",
3
+ "version": "1.3.110",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -24,5 +24,5 @@
24
24
  "@types/lodash.orderby": "^4.6.7",
25
25
  "@types/lodash.uniqby": "^4.7.7"
26
26
  },
27
- "gitHead": "2305f4c1cc75decc2dec5aadea4dac96a1c22cdc"
27
+ "gitHead": "fe501f7ff16c070a2afe4de0314651ede0a6f254"
28
28
  }
@@ -149,6 +149,11 @@ export default class ContentLayout extends LightningElement {
149
149
  this.attachInteractionObserver,
150
150
  OBSERVER_ATTACH_WAIT_TIME
151
151
  );
152
+
153
+ this.adjustNavPosition();
154
+ window.addEventListener("scroll", this.adjustNavPosition);
155
+ window.addEventListener("resize", this.adjustNavPosition);
156
+
152
157
  if (!this.hasRendered) {
153
158
  this.hasRendered = true;
154
159
  this.restoreScroll();
@@ -161,6 +166,8 @@ export default class ContentLayout extends LightningElement {
161
166
  "highlightedtermchange",
162
167
  this.updateHighlighted
163
168
  );
169
+ window.removeEventListener("scroll", this.adjustNavPosition);
170
+ window.removeEventListener("resize", this.adjustNavPosition);
164
171
  this.searchSyncer.dispose();
165
172
  this.clearRenderObserverTimer();
166
173
 
@@ -178,6 +185,61 @@ export default class ContentLayout extends LightningElement {
178
185
  }
179
186
  };
180
187
 
188
+ /*
189
+ This is a workaround for the global nav sticky header being decoupled from the doc header & doc phase.
190
+ We have to account for the global nav changing height due to animations.
191
+ */
192
+ adjustNavPosition = () => {
193
+ const sidebarType = this.useOldSidebar
194
+ ? "dx-sidebar-old"
195
+ : "dx-sidebar";
196
+ const sidebarEl = this.template.querySelector(sidebarType);
197
+ const globalNavEl = document.querySelector(
198
+ "hgf-c360nav"
199
+ ) as HTMLElement;
200
+ const contextNavEl = document.querySelector(
201
+ "hgf-c360contextnav"
202
+ ) as HTMLElement;
203
+ const docHeaderEl = document.querySelector(
204
+ ".sticky-doc-header"
205
+ ) as HTMLElement;
206
+ const docPhaseEl = document.querySelector("doc-phase") as HTMLElement;
207
+
208
+ if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
209
+ console.warn("One or more required elements are missing.");
210
+ return;
211
+ }
212
+
213
+ // sync with the browser to account for any reflows that may have happened
214
+ requestAnimationFrame(() => {
215
+ const globalNavHeight =
216
+ globalNavEl.offsetHeight + contextNavEl.offsetHeight;
217
+ const docHeaderHeight = docHeaderEl.offsetHeight;
218
+ sidebarEl.style.setProperty(
219
+ "--dx-c-content-sidebar-sticky-top",
220
+ `${globalNavHeight + docHeaderHeight}px`
221
+ );
222
+ docHeaderEl.style.setProperty(
223
+ "--dx-g-global-header-height",
224
+ `${globalNavHeight}px`
225
+ );
226
+
227
+ // If doc phase element exists, we need to account for its sticky position. Mobile should include the sidebar height (since it becomes sticky aswell).
228
+ if (docPhaseEl) {
229
+ docPhaseEl.style.setProperty(
230
+ "--doc-c-phase-top",
231
+ `${
232
+ window.innerWidth < 769
233
+ ? globalNavHeight +
234
+ docHeaderHeight +
235
+ sidebarEl.offsetHeight
236
+ : globalNavHeight + docHeaderHeight
237
+ }px`
238
+ );
239
+ }
240
+ });
241
+ };
242
+
181
243
  updateHighlighted = (event: Event): void =>
182
244
  highlightTerms(
183
245
  this.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
@@ -84,10 +84,10 @@ header:not(.has-brand) > .header_l2 {
84
84
  }
85
85
 
86
86
  .header_l2_group-title {
87
- height: var(--dx-g-doc-header-main-nav-height);
88
87
  margin-right: 0;
89
88
  padding: var(--dx-g-spacing-smd)
90
89
  var(--dx-g-global-header-padding-horizontal);
90
+ min-height: var(--dx-g-doc-header-main-nav-height);
91
91
  }
92
92
 
93
93
  .header_l2_group-title .header_lang-dropdown {
@@ -8,7 +8,7 @@ import { track } from "dxUtils/analytics";
8
8
 
9
9
  const TABLET_MATCH = "980px";
10
10
  const MOBILE_MATCH = "880px";
11
- const SMALL_MOBILE_MATCH = "740px";
11
+ const SMALL_MOBILE_MATCH = "768px";
12
12
 
13
13
  export default class Header extends HeaderBase {
14
14
  @api langValuePath: string = "id"; // allows to override how language property is interpreted, follows valuePath dropdown api.
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @lwc/lwc/no-document-query */
1
2
  import { api, track } from "lwc";
2
3
  import { normalizeBoolean } from "dxUtils/normalizers";
3
4
  import { FetchContent } from "./utils";
@@ -154,7 +155,29 @@ export default class DocXmlContent extends LightningElementWithState<{
154
155
  ));
155
156
 
156
157
  if (anchorEl) {
157
- anchorEl.scrollIntoView();
158
+ const globalNavHeader = document.querySelector(
159
+ ".global-nav-container"
160
+ ) as HTMLElement;
161
+ const docHeader = document.querySelector(
162
+ "doc-header"
163
+ ) as HTMLElement;
164
+ const headerHeight = globalNavHeader.offsetHeight;
165
+ const docHeaderHeight = docHeader.offsetHeight;
166
+ const rect = anchorEl.getBoundingClientRect();
167
+
168
+ // Calculate the scroll position required to bring the element into view
169
+ const scrollTop =
170
+ window.pageYOffset || document.documentElement.scrollTop;
171
+ const scrollX = rect.left + window.pageXOffset;
172
+ const scrollY =
173
+ rect.top + scrollTop - (headerHeight + docHeaderHeight); // subtract the header height from the top position
174
+
175
+ // Scroll to the calculated position
176
+ window.scrollTo({
177
+ top: scrollY,
178
+ left: scrollX
179
+ });
180
+
158
181
  this.setState({ internalLinkClicked: false });
159
182
  }
160
183
 
@@ -690,12 +713,17 @@ export default class DocXmlContent extends LightningElementWithState<{
690
713
  const headTag = document.getElementsByTagName("head");
691
714
  // this checks if the selected version is not the latest version,
692
715
  // then it adds the noindex, follow meta tag to the older version pages.
693
- // assumption is that first version in the availableVersions array is the latest.
716
+ const versionId = this.version.id;
717
+ const docId = this.pageReference.docId;
718
+
719
+ // SEO fix:
720
+ // Doc id without version id is always considered latest and should be used for SEO.
721
+ // Condition is to find a docId which includes version id,
722
+ // these docs are always considered as old and should not be indexed including the preview docs.
694
723
  if (
695
724
  headTag.length &&
696
- this.version &&
697
- this.availableVersions.length &&
698
- this.version.id !== this.availableVersions[0].id
725
+ docId?.includes(versionId) &&
726
+ !document.querySelector('meta[name="robots"]')
699
727
  ) {
700
728
  const robotsMeta = document.createElement("meta");
701
729
  robotsMeta.setAttribute("name", "robots");