@trackunit/iris-app-runtime-core 1.18.19 → 1.18.20
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/index.cjs.js +27 -2
- package/index.esm.js +27 -2
- package/package.json +2 -2
- package/src/getIrisAppScrollPosition.d.ts +13 -0
package/index.cjs.js
CHANGED
|
@@ -598,10 +598,35 @@ const GeolocationRuntime = {
|
|
|
598
598
|
},
|
|
599
599
|
};
|
|
600
600
|
|
|
601
|
+
const IRIS_APP_SCROLL_CONTAINER_ID = "single-spa-application:app";
|
|
602
|
+
const hasScrollableOverflow = (style) => {
|
|
603
|
+
const overflows = [style.overflow, style.overflowX, style.overflowY];
|
|
604
|
+
return overflows.some(value => value === "auto" || value === "scroll");
|
|
605
|
+
};
|
|
606
|
+
const isActivelyScrollable = (element) => element.scrollTop !== 0 ||
|
|
607
|
+
element.scrollLeft !== 0 ||
|
|
608
|
+
element.scrollHeight > element.clientHeight + 1 ||
|
|
609
|
+
element.scrollWidth > element.clientWidth + 1;
|
|
610
|
+
/**
|
|
611
|
+
* Scroll the host should restore when a modal closes.
|
|
612
|
+
*
|
|
613
|
+
* The iris app container is reported only when it can actually scroll
|
|
614
|
+
* (`overflow: auto|scroll`) and is a real scroll box. A height-constrained box
|
|
615
|
+
* with overflowing content has `scrollHeight > clientHeight` even when overflow
|
|
616
|
+
* is `visible`, and that box cannot hold a scroll offset, so falling through
|
|
617
|
+
* reports `window` instead — which older loaders and widgets still use.
|
|
618
|
+
*/
|
|
619
|
+
const getIrisAppScrollPosition = () => {
|
|
620
|
+
const container = document.getElementById(IRIS_APP_SCROLL_CONTAINER_ID);
|
|
621
|
+
if (container && hasScrollableOverflow(window.getComputedStyle(container)) && isActivelyScrollable(container)) {
|
|
622
|
+
return { scrollX: container.scrollLeft, scrollY: container.scrollTop };
|
|
623
|
+
}
|
|
624
|
+
return { scrollX: window.scrollX || 0, scrollY: window.scrollY || 0 };
|
|
625
|
+
};
|
|
626
|
+
|
|
601
627
|
const ModalDialogRuntime = {
|
|
602
628
|
async openModal() {
|
|
603
|
-
const scrollX
|
|
604
|
-
const scrollY = window.scrollY || 0;
|
|
629
|
+
const { scrollX, scrollY } = getIrisAppScrollPosition();
|
|
605
630
|
const api = await getHostConnector();
|
|
606
631
|
return api.openModal({ scrollX, scrollY });
|
|
607
632
|
},
|
package/index.esm.js
CHANGED
|
@@ -596,10 +596,35 @@ const GeolocationRuntime = {
|
|
|
596
596
|
},
|
|
597
597
|
};
|
|
598
598
|
|
|
599
|
+
const IRIS_APP_SCROLL_CONTAINER_ID = "single-spa-application:app";
|
|
600
|
+
const hasScrollableOverflow = (style) => {
|
|
601
|
+
const overflows = [style.overflow, style.overflowX, style.overflowY];
|
|
602
|
+
return overflows.some(value => value === "auto" || value === "scroll");
|
|
603
|
+
};
|
|
604
|
+
const isActivelyScrollable = (element) => element.scrollTop !== 0 ||
|
|
605
|
+
element.scrollLeft !== 0 ||
|
|
606
|
+
element.scrollHeight > element.clientHeight + 1 ||
|
|
607
|
+
element.scrollWidth > element.clientWidth + 1;
|
|
608
|
+
/**
|
|
609
|
+
* Scroll the host should restore when a modal closes.
|
|
610
|
+
*
|
|
611
|
+
* The iris app container is reported only when it can actually scroll
|
|
612
|
+
* (`overflow: auto|scroll`) and is a real scroll box. A height-constrained box
|
|
613
|
+
* with overflowing content has `scrollHeight > clientHeight` even when overflow
|
|
614
|
+
* is `visible`, and that box cannot hold a scroll offset, so falling through
|
|
615
|
+
* reports `window` instead — which older loaders and widgets still use.
|
|
616
|
+
*/
|
|
617
|
+
const getIrisAppScrollPosition = () => {
|
|
618
|
+
const container = document.getElementById(IRIS_APP_SCROLL_CONTAINER_ID);
|
|
619
|
+
if (container && hasScrollableOverflow(window.getComputedStyle(container)) && isActivelyScrollable(container)) {
|
|
620
|
+
return { scrollX: container.scrollLeft, scrollY: container.scrollTop };
|
|
621
|
+
}
|
|
622
|
+
return { scrollX: window.scrollX || 0, scrollY: window.scrollY || 0 };
|
|
623
|
+
};
|
|
624
|
+
|
|
599
625
|
const ModalDialogRuntime = {
|
|
600
626
|
async openModal() {
|
|
601
|
-
const scrollX
|
|
602
|
-
const scrollY = window.scrollY || 0;
|
|
627
|
+
const { scrollX, scrollY } = getIrisAppScrollPosition();
|
|
603
628
|
const api = await getHostConnector();
|
|
604
629
|
return api.openModal({ scrollX, scrollY });
|
|
605
630
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app-runtime-core",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.20",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"penpal": "^7.0.6",
|
|
11
|
-
"@trackunit/iris-app-runtime-core-api": "1.17.
|
|
11
|
+
"@trackunit/iris-app-runtime-core-api": "1.17.20"
|
|
12
12
|
},
|
|
13
13
|
"migrations": "./migrations.json",
|
|
14
14
|
"module": "./index.esm.js",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scroll the host should restore when a modal closes.
|
|
3
|
+
*
|
|
4
|
+
* The iris app container is reported only when it can actually scroll
|
|
5
|
+
* (`overflow: auto|scroll`) and is a real scroll box. A height-constrained box
|
|
6
|
+
* with overflowing content has `scrollHeight > clientHeight` even when overflow
|
|
7
|
+
* is `visible`, and that box cannot hold a scroll offset, so falling through
|
|
8
|
+
* reports `window` instead — which older loaders and widgets still use.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getIrisAppScrollPosition: () => {
|
|
11
|
+
scrollX: number;
|
|
12
|
+
scrollY: number;
|
|
13
|
+
};
|