@sb1/ffe-modals-react 0.3.1 → 0.3.2
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/es/Modal.js +6 -4
- package/lib/Modal.js +6 -4
- package/package.json +3 -3
package/es/Modal.js
CHANGED
|
@@ -27,6 +27,7 @@ export var Modal = React.forwardRef(function (_a, ref) {
|
|
|
27
27
|
var children = _a.children, onClick = _a.onClick, ariaLabelledby = _a.ariaLabelledby, className = _a.className, _b = _a.locale, locale = _b === void 0 ? 'nb' : _b, onClose = _a.onClose, rest = __rest(_a, ["children", "onClick", "ariaLabelledby", "className", "locale", "onClose"]);
|
|
28
28
|
var _c = useState(false), isOpen = _c[0], setIsOpen = _c[1];
|
|
29
29
|
var modalRef = useRef(null);
|
|
30
|
+
var htmlOverflowY = useRef(document.documentElement.style.overflowY);
|
|
30
31
|
useImperativeHandle(ref, function () { return ({
|
|
31
32
|
open: function () {
|
|
32
33
|
var _a;
|
|
@@ -40,14 +41,15 @@ export var Modal = React.forwardRef(function (_a, ref) {
|
|
|
40
41
|
}); });
|
|
41
42
|
useEffect(function () {
|
|
42
43
|
var _a;
|
|
44
|
+
var html = document.documentElement;
|
|
43
45
|
var inShadow = ((_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.getRootNode()) instanceof ShadowRoot;
|
|
44
46
|
if (inShadow) {
|
|
45
|
-
var html = document.documentElement;
|
|
46
47
|
if (isOpen) {
|
|
47
|
-
html.
|
|
48
|
+
htmlOverflowY.current = html.style.overflowY;
|
|
49
|
+
html.style.overflowY = 'hidden';
|
|
48
50
|
}
|
|
49
|
-
else {
|
|
50
|
-
html.
|
|
51
|
+
else if (!isOpen) {
|
|
52
|
+
html.style.overflowY = htmlOverflowY.current;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}, [isOpen]);
|
package/lib/Modal.js
CHANGED
|
@@ -56,6 +56,7 @@ exports.Modal = react_1.default.forwardRef(function (_a, ref) {
|
|
|
56
56
|
var children = _a.children, onClick = _a.onClick, ariaLabelledby = _a.ariaLabelledby, className = _a.className, _b = _a.locale, locale = _b === void 0 ? 'nb' : _b, onClose = _a.onClose, rest = __rest(_a, ["children", "onClick", "ariaLabelledby", "className", "locale", "onClose"]);
|
|
57
57
|
var _c = (0, react_1.useState)(false), isOpen = _c[0], setIsOpen = _c[1];
|
|
58
58
|
var modalRef = (0, react_1.useRef)(null);
|
|
59
|
+
var htmlOverflowY = (0, react_1.useRef)(document.documentElement.style.overflowY);
|
|
59
60
|
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
60
61
|
open: function () {
|
|
61
62
|
var _a;
|
|
@@ -69,14 +70,15 @@ exports.Modal = react_1.default.forwardRef(function (_a, ref) {
|
|
|
69
70
|
}); });
|
|
70
71
|
(0, react_1.useEffect)(function () {
|
|
71
72
|
var _a;
|
|
73
|
+
var html = document.documentElement;
|
|
72
74
|
var inShadow = ((_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.getRootNode()) instanceof ShadowRoot;
|
|
73
75
|
if (inShadow) {
|
|
74
|
-
var html = document.documentElement;
|
|
75
76
|
if (isOpen) {
|
|
76
|
-
html.
|
|
77
|
+
htmlOverflowY.current = html.style.overflowY;
|
|
78
|
+
html.style.overflowY = 'hidden';
|
|
77
79
|
}
|
|
78
|
-
else {
|
|
79
|
-
html.
|
|
80
|
+
else if (!isOpen) {
|
|
81
|
+
html.style.overflowY = htmlOverflowY.current;
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
}, [isOpen]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-modals-react",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "SpareBank 1",
|
|
6
6
|
"files": [
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@sb1/ffe-icons-react": "^10.0.5",
|
|
29
|
-
"@sb1/ffe-modals": "^0.2.
|
|
29
|
+
"@sb1/ffe-modals": "^0.2.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@sb1/ffe-buildtool": "^0.6.4",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "1c5e740703711efb9002c4ed8f86e0e4f6356ceb"
|
|
44
44
|
}
|