Skip to content

Commit 74a7b3e

Browse files
committed
[PRAC/cont] Fix error with "aria-hidden" attribute
Organiz forced deleting aria-hidden="true" attr from add-modal window. Worth noting: - automatic/couloir addition of this attribute (internal Bootstrap logics). core: B-3 / JS-BL
1 parent bba1fec commit 74a7b3e

File tree

1 file changed

+21
-2
lines changed
  • core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-client/js

1 file changed

+21
-2
lines changed

core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-client/js/index.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,6 @@
379379
addBtn.setAttribute('data-bs-toggle', 'modal');
380380
addBtn.setAttribute('data-bs-target', '#add-btn-modal');
381381
addModalWrap.setAttribute('id', 'add-btn-modal');
382-
addModalWrap.setAttribute('tabindex', '-1');
383-
// addModalWrap.setAttribute('aria-hidden', 'true');
384382
addModalHeaderXBtn.setAttribute('type', 'button');
385383
addModalHeaderXBtn.setAttribute('data-bs-dismiss', 'modal');
386384
addModalHeaderXBtn.setAttribute('aria-label', 'Close');
@@ -769,6 +767,27 @@
769767
});
770768
});
771769

770+
// ** организация принудительного удаления атрибута aria-hidden="true" с Bootstrap-модального окна (исключение ошибки с ARIA)
771+
const addModal = document.querySelector('.crm__add-btn-modal');
772+
773+
// мониторинг/ожидание появления соответствующего атрибута
774+
const observer = new MutationObserver((mutationsList) => {
775+
mutationsList.forEach((mutation) => {
776+
if (
777+
mutation.type === 'attributes' &&
778+
mutation.attributeName === 'aria-hidden'
779+
) {
780+
addModal.removeAttribute('aria-hidden'); // принудительное удаление
781+
}
782+
});
783+
});
784+
785+
// запуск мониторинга
786+
observer.observe(addModal, { attributes: true });
787+
788+
// остановка мониторинга (если более не требуется)
789+
// observer.disconnect();
790+
772791
// ** динамическое добавление строки контактов в add-модальном окне (по нажатию "Добавить контакт" кнопки)
773792
const addModalContactsArr = [];
774793

0 commit comments

Comments
 (0)