@sb1/ffe-modals-react 102.0.13 → 102.0.15
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 +13 -4
- package/lib/Modal.js +13 -4
- package/package.json +6 -6
package/es/Modal.js
CHANGED
|
@@ -10,15 +10,17 @@ export const Modal = React.forwardRef(({ children, onClick, ariaLabelledby, clas
|
|
|
10
10
|
const htmlOverflowY = useRef(isClient ? document.documentElement.style.overflowY : '');
|
|
11
11
|
useImperativeHandle(ref, () => ({
|
|
12
12
|
open: () => {
|
|
13
|
-
// Prevent opening an already open modal
|
|
14
|
-
|
|
13
|
+
// Prevent opening an already open modal. Ask the dialog, not isOpen: isOpen becomes false
|
|
14
|
+
// only in the close event, and the browser fires that event in a later task than close().
|
|
15
|
+
if (dialogRef.current && !dialogRef.current.open) {
|
|
15
16
|
setIsOpen(true);
|
|
16
17
|
dialogRef.current.showModal();
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
20
|
close: () => {
|
|
21
|
+
var _a;
|
|
20
22
|
// Prevent closing an already closed modal
|
|
21
|
-
if (
|
|
23
|
+
if ((_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.open) {
|
|
22
24
|
dialogRef.current.close();
|
|
23
25
|
}
|
|
24
26
|
},
|
|
@@ -73,8 +75,15 @@ export const Modal = React.forwardRef(({ children, onClick, ariaLabelledby, clas
|
|
|
73
75
|
}
|
|
74
76
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
75
77
|
}, onClose: () => {
|
|
76
|
-
|
|
78
|
+
var _a;
|
|
79
|
+
// A close event from an earlier close() still fires when the dialog has been
|
|
80
|
+
// opened again in the meantime. The dialog is not closed then.
|
|
81
|
+
if ((_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.open) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Before onClose, so that isOpen stays true when onClose opens the modal again.
|
|
77
85
|
setIsOpen(false);
|
|
86
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
78
87
|
} },
|
|
79
88
|
React.createElement("div", { className: "ffe-modal__body" },
|
|
80
89
|
React.createElement(CloseButton, { onClick: () => { var _a; return (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, locale: locale }),
|
package/lib/Modal.js
CHANGED
|
@@ -49,15 +49,17 @@ exports.Modal = react_1.default.forwardRef(({ children, onClick, ariaLabelledby,
|
|
|
49
49
|
const htmlOverflowY = (0, react_1.useRef)(isClient ? document.documentElement.style.overflowY : '');
|
|
50
50
|
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
51
51
|
open: () => {
|
|
52
|
-
// Prevent opening an already open modal
|
|
53
|
-
|
|
52
|
+
// Prevent opening an already open modal. Ask the dialog, not isOpen: isOpen becomes false
|
|
53
|
+
// only in the close event, and the browser fires that event in a later task than close().
|
|
54
|
+
if (dialogRef.current && !dialogRef.current.open) {
|
|
54
55
|
setIsOpen(true);
|
|
55
56
|
dialogRef.current.showModal();
|
|
56
57
|
}
|
|
57
58
|
},
|
|
58
59
|
close: () => {
|
|
60
|
+
var _a;
|
|
59
61
|
// Prevent closing an already closed modal
|
|
60
|
-
if (
|
|
62
|
+
if ((_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.open) {
|
|
61
63
|
dialogRef.current.close();
|
|
62
64
|
}
|
|
63
65
|
},
|
|
@@ -112,8 +114,15 @@ exports.Modal = react_1.default.forwardRef(({ children, onClick, ariaLabelledby,
|
|
|
112
114
|
}
|
|
113
115
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
114
116
|
}, onClose: () => {
|
|
115
|
-
|
|
117
|
+
var _a;
|
|
118
|
+
// A close event from an earlier close() still fires when the dialog has been
|
|
119
|
+
// opened again in the meantime. The dialog is not closed then.
|
|
120
|
+
if ((_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.open) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// Before onClose, so that isOpen stays true when onClose opens the modal again.
|
|
116
124
|
setIsOpen(false);
|
|
125
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
117
126
|
} },
|
|
118
127
|
react_1.default.createElement("div", { className: "ffe-modal__body" },
|
|
119
128
|
react_1.default.createElement(CloseButton_1.CloseButton, { onClick: () => { var _a; return (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, locale: locale }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-modals-react",
|
|
3
|
-
"version": "102.0.
|
|
3
|
+
"version": "102.0.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "SpareBank 1",
|
|
6
6
|
"files": [
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"test:watch": "ffe-buildtool jest --watch"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@sb1/ffe-buttons-react": "^102.0.
|
|
28
|
-
"@sb1/ffe-icons-react": "^102.0.
|
|
29
|
-
"@sb1/ffe-modals": "^102.0.
|
|
27
|
+
"@sb1/ffe-buttons-react": "^102.0.15",
|
|
28
|
+
"@sb1/ffe-icons-react": "^102.0.15",
|
|
29
|
+
"@sb1/ffe-modals": "^102.0.15",
|
|
30
30
|
"classnames": "^2.5.1",
|
|
31
31
|
"dialog-polyfill": "^0.5.6"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@sb1/ffe-buildtool": "^102.0.
|
|
34
|
+
"@sb1/ffe-buildtool": "^102.0.15",
|
|
35
35
|
"react": "^18.2.0",
|
|
36
36
|
"react-dom": "^18.2.0"
|
|
37
37
|
},
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "0068ae76260af9fc428e22901df0daf118e466cc"
|
|
45
45
|
}
|