frayerjj-frontend 0.8.9 → 0.8.10
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/package.json +1 -1
- package/src/modal.js +14 -7
package/package.json
CHANGED
package/src/modal.js
CHANGED
|
@@ -39,6 +39,7 @@ export const modal = {
|
|
|
39
39
|
ev.target.remove();
|
|
40
40
|
});
|
|
41
41
|
let bsAjaxModal = Modal.getOrCreateInstance(ajaxModal);
|
|
42
|
+
modal._lastFocus = document.activeElement;
|
|
42
43
|
bsAjaxModal.show();
|
|
43
44
|
loading.start(0, ajaxModalBody);
|
|
44
45
|
msg.verbose('Loading AJAX Modal');
|
|
@@ -93,7 +94,7 @@ export const modal = {
|
|
|
93
94
|
|
|
94
95
|
alert: (messsage, title = "Alert", button = "OK") => {
|
|
95
96
|
msg.verbose('Building Alert Modal');
|
|
96
|
-
let randomId = modal.randomId('
|
|
97
|
+
let randomId = modal.randomId('alert');
|
|
97
98
|
document.querySelector('body').insertAdjacentHTML('beforeend', modal.build.modal({
|
|
98
99
|
id: randomId,
|
|
99
100
|
title: title,
|
|
@@ -108,7 +109,7 @@ export const modal = {
|
|
|
108
109
|
alertModal.addEventListener('hidden.bs.modal', ev => {
|
|
109
110
|
ev.target.remove();
|
|
110
111
|
});
|
|
111
|
-
modal.
|
|
112
|
+
modal._lastFocus = document.activeElement;
|
|
112
113
|
bsAlertModal.show();
|
|
113
114
|
},
|
|
114
115
|
|
|
@@ -292,15 +293,21 @@ export const modal = {
|
|
|
292
293
|
confirmModal.querySelector('.btn-outline-danger').addEventListener('click', () => {
|
|
293
294
|
onCancel();
|
|
294
295
|
});
|
|
295
|
-
modal.
|
|
296
|
+
modal._lastFocus = document.activeElement;
|
|
296
297
|
bsConfirmModal.show();
|
|
297
298
|
},
|
|
298
299
|
|
|
299
300
|
focusFix: () => {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
setTimeout(() => {
|
|
302
|
+
if (modal._lastFocus && document.contains(modal._lastFocus)) {
|
|
303
|
+
modal._lastFocus.focus();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const fallback = document.querySelector('main') || document.body;
|
|
307
|
+
if (!fallback.hasAttribute('tabindex'))
|
|
308
|
+
fallback.setAttribute('tabindex', '-1');
|
|
309
|
+
fallback.focus();
|
|
310
|
+
}, 0);
|
|
304
311
|
},
|
|
305
312
|
|
|
306
313
|
randomId: (base = 'modal') => {
|