@salesforcedevs/dx-components 1.3.43 → 1.3.44

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/dx-components",
3
- "version": "1.3.43",
3
+ "version": "1.3.44",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -40,5 +40,5 @@
40
40
  "eventsourcemock": "^2.0.0",
41
41
  "luxon": "^3.1.0"
42
42
  },
43
- "gitHead": "de82bbf2fd1ea6664ceed1233ccf4aed43ac19ec"
43
+ "gitHead": "6fd47c4a90b3238225555542a33e2f10246cbc5b"
44
44
  }
@@ -9,7 +9,13 @@ declare module globalThis {
9
9
  let singletonScrollManagerConnected: boolean;
10
10
  }
11
11
  // mostly components shouldn't be using this, but there are a few exceptions such as amfReference
12
+
13
+ let scrollUnlocked: boolean = false;
14
+
12
15
  export const restoreScroll = () => {
16
+ if (scrollUnlocked) {
17
+ return;
18
+ }
13
19
  document.body.scrollTop = document.documentElement.scrollTop =
14
20
  window.history.state?.scroll.value;
15
21
  };
@@ -33,10 +39,10 @@ export default class ScrollManager extends LightningElement {
33
39
  */
34
40
 
35
41
  protected scrollCount = 0; // this is for dark magic, basically we lock the user out of scrolling in the first quarter second, unless they really mean it. We do this because load timings mean that the scroll can get messed up in that period
36
- protected scrollUnlocked = false;
37
42
 
38
43
  renderedCallback() {
39
- if (!globalThis.singletonScrollManagerRendered) {
44
+ scrollUnlocked = window.location.hash !== ""; // if we have anchor links, skip the entire scroll restore
45
+ if (!globalThis.singletonScrollManagerRendered && !scrollUnlocked) {
40
46
  globalThis.singletonScrollManagerRendered = true;
41
47
  if (
42
48
  window.history.state?.scroll?.docSize ===
@@ -50,10 +56,8 @@ export default class ScrollManager extends LightningElement {
50
56
  // sometimes loading is slow, so we may want to reset the scroll to
51
57
  // the correct position after loading is complete, to avoid weird behavior
52
58
  // but only if the user hasn't scrolled around in the meantime
53
- if (!this.scrollUnlocked) {
54
- restoreScroll();
55
- this.scrollUnlocked = true;
56
- }
59
+ restoreScroll();
60
+ scrollUnlocked = true;
57
61
  }, LOAD_TIME_SCROLL_RESTORE_DELAY);
58
62
  }
59
63
  } else {