linear-react-components-ui 1.1.2-beta.5 → 1.1.2-beta.7
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/lib/dialog/base/index.js +0 -23
- package/package.json +1 -1
package/lib/dialog/base/index.js
CHANGED
|
@@ -121,32 +121,9 @@ const BaseDialog = props => {
|
|
|
121
121
|
}, children)));
|
|
122
122
|
(0, _react.useEffect)(() => {
|
|
123
123
|
if (open) {
|
|
124
|
-
var _wrapperEl$current;
|
|
125
124
|
if (closeOnEsc) {
|
|
126
125
|
document.addEventListener('keydown', handleCloseOnEsc);
|
|
127
126
|
}
|
|
128
|
-
const modalContent = (_wrapperEl$current = wrapperEl.current) === null || _wrapperEl$current === void 0 ? void 0 : _wrapperEl$current.querySelector('#modal-dialog-content');
|
|
129
|
-
const modalElementsForTrapFocus = (modalContent === null || modalContent === void 0 ? void 0 : modalContent.querySelectorAll('[href], input, select, textarea, button, [tabindex]:not([tabindex="-1"]) button:not([id="botao-fechar-modal-cabecalho"])')) || [];
|
|
130
|
-
if (wrapperEl && wrapperEl.current && modalElementsForTrapFocus.length) {
|
|
131
|
-
const firstElementInModal = modalElementsForTrapFocus[0];
|
|
132
|
-
const lastElementInModal = modalElementsForTrapFocus[modalElementsForTrapFocus.length - 1];
|
|
133
|
-
const handleTabKeyPress = event => {
|
|
134
|
-
if (event.key === 'Tab') {
|
|
135
|
-
if (event.shiftKey && document.activeElement === firstElementInModal) {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
lastElementInModal.focus();
|
|
138
|
-
} else if (!event.shiftKey && document.activeElement === lastElementInModal) {
|
|
139
|
-
event.preventDefault();
|
|
140
|
-
firstElementInModal.focus();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
wrapperEl.current.addEventListener('keydown', handleTabKeyPress);
|
|
145
|
-
return () => {
|
|
146
|
-
var _wrapperEl$current2;
|
|
147
|
-
(_wrapperEl$current2 = wrapperEl.current) === null || _wrapperEl$current2 === void 0 ? void 0 : _wrapperEl$current2.removeEventListener('keydown', handleTabKeyPress);
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
127
|
}
|
|
151
128
|
return () => {
|
|
152
129
|
document.removeEventListener('keydown', handleCloseOnEsc);
|