@reshaped/utilities 4.0.1 → 4.0.3
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/dist/flyout/Flyout.js
CHANGED
|
@@ -18,7 +18,7 @@ class Flyout {
|
|
|
18
18
|
return result;
|
|
19
19
|
};
|
|
20
20
|
#addParentScrollHandler = () => {
|
|
21
|
-
const { trigger, onDeactivate
|
|
21
|
+
const { trigger, onDeactivate } = this.#options;
|
|
22
22
|
if (!trigger)
|
|
23
23
|
return;
|
|
24
24
|
const container = findClosestScrollableContainer({ el: trigger });
|
|
@@ -26,22 +26,16 @@ class Flyout {
|
|
|
26
26
|
const handleScroll = rafThrottle(() => {
|
|
27
27
|
if (!this.#active)
|
|
28
28
|
return;
|
|
29
|
-
if (!container
|
|
29
|
+
if (!container) {
|
|
30
30
|
this.#update();
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
const triggerBounds = trigger.getBoundingClientRect();
|
|
34
|
-
const containerBounds = container
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
bottom: containerBounds?.bottom ?? window.innerHeight,
|
|
40
|
-
};
|
|
41
|
-
if (triggerBounds.top < visibilityBounds.top ||
|
|
42
|
-
triggerBounds.left < visibilityBounds.left ||
|
|
43
|
-
triggerBounds.right > visibilityBounds.right ||
|
|
44
|
-
triggerBounds.bottom > visibilityBounds.bottom) {
|
|
34
|
+
const containerBounds = container.getBoundingClientRect();
|
|
35
|
+
if (triggerBounds.top < containerBounds.top ||
|
|
36
|
+
triggerBounds.left < containerBounds.left ||
|
|
37
|
+
triggerBounds.right > containerBounds.right ||
|
|
38
|
+
triggerBounds.bottom > containerBounds.bottom) {
|
|
45
39
|
onDeactivate();
|
|
46
40
|
}
|
|
47
41
|
else {
|
|
@@ -105,6 +105,27 @@ describe("flyout/Flyout", () => {
|
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
107
|
});
|
|
108
|
+
test("keeps flyout open on window scroll with layout adjustment", () => {
|
|
109
|
+
const flyout = new Flyout({
|
|
110
|
+
content,
|
|
111
|
+
trigger,
|
|
112
|
+
triggerCoordinates: null,
|
|
113
|
+
position: "top",
|
|
114
|
+
fallbackAdjustLayout: true,
|
|
115
|
+
onDeactivate: onClose,
|
|
116
|
+
});
|
|
117
|
+
flyout.activate();
|
|
118
|
+
trigger.style.top = "-100px";
|
|
119
|
+
window.dispatchEvent(new Event("scroll"));
|
|
120
|
+
return new Promise((resolve) => {
|
|
121
|
+
requestAnimationFrame(() => {
|
|
122
|
+
requestAnimationFrame(() => {
|
|
123
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
124
|
+
resolve(undefined);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
108
129
|
test("updates position on RTL direction change", async () => {
|
|
109
130
|
const flyout = new Flyout({
|
|
110
131
|
content,
|