@salesforcedevs/dx-components 1.3.20 → 1.3.22
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/lwc.config.json +1 -0
- package/package.json +2 -2
- package/src/modules/dx/header/header.html +1 -1
- package/src/modules/dx/header/header.ts +4 -0
- package/src/modules/dx/scrollManager/scrollManager.html +1 -0
- package/src/modules/dx/scrollManager/scrollManager.ts +105 -0
- package/src/modules/dx/searchResults/searchResults.css +2 -2
- package/src/modules/dx/tbidAvatarButton/tbidAvatarButton.css +2 -2
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.22",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"eventsourcemock": "^2.0.0",
|
|
39
39
|
"luxon": "^3.1.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "78accbacab7e5ff5cc7cf327092884064a86d78f"
|
|
42
42
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<template></template>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { LightningElement } from "lwc";
|
|
2
|
+
|
|
3
|
+
const RESTORE_SCROLL_EVENT_NAME = "restore-scroll";
|
|
4
|
+
const LOAD_TIME_SCROLL_RESTORE_DELAY = 750;
|
|
5
|
+
|
|
6
|
+
declare module globalThis {
|
|
7
|
+
let singletonScrollManagerRendered: boolean;
|
|
8
|
+
let singletonScrollManagerConnected: boolean;
|
|
9
|
+
}
|
|
10
|
+
// mostly components shouldn't be using this, but there are a few exceptions such as amfReference
|
|
11
|
+
export const restoreScroll = () => {
|
|
12
|
+
document.body.scrollTop = document.documentElement.scrollTop =
|
|
13
|
+
window.history.state?.scroll.value;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default class ScrollManager extends LightningElement {
|
|
17
|
+
/*
|
|
18
|
+
WARNING: Dark Magic(TM) follows. This code is likely to be unreliable if:
|
|
19
|
+
- Our load times significantly change (in this case, LOAD_TIME_SCROLL_RESTORE_DELAY may need to be adjusted)
|
|
20
|
+
- Any other components attempt to manipulate the body scroll (including #a links) before LOAD_TIME_SCROLL_RESTORE_DELAY has expired
|
|
21
|
+
|
|
22
|
+
This Dark Magic(TM) was required because of the following super annoying race condition occuring while trying to restore scroll position:
|
|
23
|
+
1. Load a page on our site (reproducible consistently at time of writing at https://developer.salesforce.com)
|
|
24
|
+
2. Scroll down somewhere (remember where)
|
|
25
|
+
3. Navigate to another page
|
|
26
|
+
4. Navigate back/forward/back, using the browser forward/back buttons (sometimes it takes a few tries to reproduce the race condition)
|
|
27
|
+
5. If the page you're on takes long enough for its components to finish rendering asynchronously, sometimes your scroll position will be incorrect
|
|
28
|
+
(until the second scroll restore is called. To see the really bad behavior, simply remove the window.setTimeout bit)
|
|
29
|
+
This is because basically it scrolls you down a bit, then a component gets bigger above you as it finishes rendering
|
|
30
|
+
This pushes your whole view down, so unless we do this Dark Magic(TM) where we attempt to restore scroll _again_
|
|
31
|
+
after some reasonable interval, your window will be in the wrong spot when everything finishes rendering
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
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
|
|
35
|
+
protected scrollUnlocked = false;
|
|
36
|
+
|
|
37
|
+
renderedCallback() {
|
|
38
|
+
if (!globalThis.singletonScrollManagerRendered) {
|
|
39
|
+
globalThis.singletonScrollManagerRendered = true;
|
|
40
|
+
if (
|
|
41
|
+
window.history.state?.scroll.docSize ===
|
|
42
|
+
document.body.scrollHeight
|
|
43
|
+
) {
|
|
44
|
+
// only do this if loading is complete and the scrollHeight matches expectations
|
|
45
|
+
// otherwise, we're likely still loading, so just chill to avoid jumping around so much
|
|
46
|
+
restoreScroll();
|
|
47
|
+
} else {
|
|
48
|
+
window.setTimeout(() => {
|
|
49
|
+
// sometimes loading is slow, so we may want to reset the scroll to
|
|
50
|
+
// the correct position after loading is complete, to avoid weird behavior
|
|
51
|
+
// but only if the user hasn't scrolled around in the meantime
|
|
52
|
+
if (!this.scrollUnlocked) {
|
|
53
|
+
restoreScroll();
|
|
54
|
+
this.scrollUnlocked = true;
|
|
55
|
+
}
|
|
56
|
+
}, LOAD_TIME_SCROLL_RESTORE_DELAY);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
console.error(
|
|
60
|
+
"Multiple <dx-scroll-manager>s detected, this should never be the case."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
connectedCallback(): void {
|
|
66
|
+
if (!globalThis.singletonScrollManagerConnected) {
|
|
67
|
+
globalThis.singletonScrollManagerConnected = true;
|
|
68
|
+
window.addEventListener(RESTORE_SCROLL_EVENT_NAME, restoreScroll);
|
|
69
|
+
|
|
70
|
+
document.body.addEventListener("scroll", this.manualScrollListener);
|
|
71
|
+
} else {
|
|
72
|
+
console.error(
|
|
73
|
+
"Multiple <dx-scroll-manager>s detected, this should never be the case."
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
saveScroll = () => {
|
|
79
|
+
window.history.replaceState(
|
|
80
|
+
{
|
|
81
|
+
scroll: {
|
|
82
|
+
value: document.body.scrollTop,
|
|
83
|
+
docSize: document.body.scrollHeight
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"",
|
|
87
|
+
window.location.href
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
manualScrollListener = () => {
|
|
92
|
+
if (this.scrollCount < 5) {
|
|
93
|
+
this.scrollCount++;
|
|
94
|
+
} else {
|
|
95
|
+
this.scrollUnlocked = true;
|
|
96
|
+
}
|
|
97
|
+
if (this.scrollUnlocked) {
|
|
98
|
+
this.saveScroll();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
disconnectedCallback(): void {
|
|
103
|
+
window.removeEventListener(RESTORE_SCROLL_EVENT_NAME, restoreScroll);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -197,8 +197,8 @@ li.coveo-dynamic-facet-breadcrumb-value-list-item {
|
|
|
197
197
|
|
|
198
198
|
.CoveoSort.coveo-selected,
|
|
199
199
|
.CoveoSort.coveo-selected:hover {
|
|
200
|
-
color: var(--dx-g-blue-vibrant-
|
|
201
|
-
border-bottom-color: var(--dx-g-blue-vibrant-
|
|
200
|
+
color: var(--dx-g-blue-vibrant-40);
|
|
201
|
+
border-bottom-color: var(--dx-g-blue-vibrant-40);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
.CoveoBreadcrumb {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
@import "dxHelpers/reset";
|
|
2
2
|
|
|
3
3
|
:host {
|
|
4
|
-
--dx-c-button-custom-color: var(--dx-g-blue-vibrant-
|
|
4
|
+
--dx-c-button-custom-color: var(--dx-g-blue-vibrant-40);
|
|
5
5
|
--dx-c-button-custom-background: transparent;
|
|
6
6
|
--dx-c-button-custom-border: 1px solid transparent;
|
|
7
|
-
--dx-c-button-custom-color-hover: var(--dx-g-blue-vibrant-
|
|
7
|
+
--dx-c-button-custom-color-hover: var(--dx-g-blue-vibrant-40);
|
|
8
8
|
--dx-c-button-custom-background-hover: var(--dx-g-cloud-blue-vibrant-90);
|
|
9
9
|
--dx-c-button-custom-border-hover: var(--dx-g-cloud-blue-vibrant-90);
|
|
10
10
|
--dx-c-slot-empty-width: max-content;
|