@elliemae/ds-dialog 2.3.1-rc.0 → 2.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/cjs/DSDialog.js +12 -2
- package/esm/DSDialog.js +12 -2
- package/package.json +7 -7
package/cjs/DSDialog.js
CHANGED
|
@@ -58,6 +58,16 @@ const DSDialog = props => {
|
|
|
58
58
|
rest = _objectWithoutProperties__default["default"](propsWithDefault, _excluded);
|
|
59
59
|
|
|
60
60
|
const containerRef = react.useRef(null);
|
|
61
|
+
const focusContainer = react.useCallback(() => {
|
|
62
|
+
var _containerRef$current, _containerRef$current2, _containerRef$current3;
|
|
63
|
+
|
|
64
|
+
const isContainerOrChildFocused = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.contains(document.activeElement);
|
|
65
|
+
if (!isContainerOrChildFocused) (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : (_containerRef$current3 = _containerRef$current2.focus) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.call(_containerRef$current2);
|
|
66
|
+
}, []);
|
|
67
|
+
react.useEffect(() => {
|
|
68
|
+
document.addEventListener('focusin', focusContainer);
|
|
69
|
+
return () => document.removeEventListener('focusin', focusContainer);
|
|
70
|
+
}, [focusContainer]);
|
|
61
71
|
const handleOutsideClick = react.useCallback(e => {
|
|
62
72
|
if (e.target.dataset.portalbg) onClickOutside();
|
|
63
73
|
}, [onClickOutside]);
|
|
@@ -93,9 +103,9 @@ const DSDialog = props => {
|
|
|
93
103
|
});
|
|
94
104
|
}, [isOpen]);
|
|
95
105
|
react.useEffect(() => {
|
|
96
|
-
var _containerRef$
|
|
106
|
+
var _containerRef$current4;
|
|
97
107
|
|
|
98
|
-
if (isOpen && !removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$
|
|
108
|
+
if (isOpen && !removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.focus();
|
|
99
109
|
}, [isOpen, removeAutoFocus]);
|
|
100
110
|
|
|
101
111
|
if (isOpen) {
|
package/esm/DSDialog.js
CHANGED
|
@@ -47,6 +47,16 @@ const DSDialog = props => {
|
|
|
47
47
|
rest = _objectWithoutProperties(propsWithDefault, _excluded);
|
|
48
48
|
|
|
49
49
|
const containerRef = useRef(null);
|
|
50
|
+
const focusContainer = useCallback(() => {
|
|
51
|
+
var _containerRef$current, _containerRef$current2, _containerRef$current3;
|
|
52
|
+
|
|
53
|
+
const isContainerOrChildFocused = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.contains(document.activeElement);
|
|
54
|
+
if (!isContainerOrChildFocused) (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : (_containerRef$current3 = _containerRef$current2.focus) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.call(_containerRef$current2);
|
|
55
|
+
}, []);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
document.addEventListener('focusin', focusContainer);
|
|
58
|
+
return () => document.removeEventListener('focusin', focusContainer);
|
|
59
|
+
}, [focusContainer]);
|
|
50
60
|
const handleOutsideClick = useCallback(e => {
|
|
51
61
|
if (e.target.dataset.portalbg) onClickOutside();
|
|
52
62
|
}, [onClickOutside]);
|
|
@@ -82,9 +92,9 @@ const DSDialog = props => {
|
|
|
82
92
|
});
|
|
83
93
|
}, [isOpen]);
|
|
84
94
|
useEffect(() => {
|
|
85
|
-
var _containerRef$
|
|
95
|
+
var _containerRef$current4;
|
|
86
96
|
|
|
87
|
-
if (isOpen && !removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$
|
|
97
|
+
if (isOpen && !removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.focus();
|
|
88
98
|
}, [isOpen, removeAutoFocus]);
|
|
89
99
|
|
|
90
100
|
if (isOpen) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-dialog",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Dialog",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -60,17 +60,17 @@
|
|
|
60
60
|
"build": "node ../../scripts/build/build.js"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@elliemae/ds-button": "2.3.
|
|
64
|
-
"@elliemae/ds-icons": "2.3.
|
|
65
|
-
"@elliemae/ds-props-helpers": "2.3.
|
|
66
|
-
"@elliemae/ds-system": "2.3.
|
|
67
|
-
"@xstyled/styled-components": "~3.1.1",
|
|
63
|
+
"@elliemae/ds-button": "2.3.2",
|
|
64
|
+
"@elliemae/ds-icons": "2.3.2",
|
|
65
|
+
"@elliemae/ds-props-helpers": "2.3.2",
|
|
66
|
+
"@elliemae/ds-system": "2.3.2",
|
|
68
67
|
"react-desc": "~4.1.3"
|
|
69
68
|
},
|
|
70
69
|
"devDependencies": {
|
|
71
|
-
"
|
|
70
|
+
"@testing-library/react": "~12.1.2"
|
|
72
71
|
},
|
|
73
72
|
"peerDependencies": {
|
|
73
|
+
"@xstyled/styled-components": "~3.1.1",
|
|
74
74
|
"react": "^17.0.2",
|
|
75
75
|
"react-dom": "^17.0.2",
|
|
76
76
|
"styled-components": "^5.3.3"
|