Skip to content

Commit 7199406

Browse files
committed
[PRAC/cont] Add log/correct "z-index" for drop-btn
Organiz "z-index" correct for drop-btn, when "focus" (overlap row-inpt). Worth noting: - that CSS couldn't do it. core: B-3 / JS-BL
1 parent 6218389 commit 7199406

File tree

1 file changed

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

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,9 @@
13341334
deleteModalRowContacts(context);
13351335
});
13361336

1337+
// корректировка z-index у/для drop-btn кнопки
1338+
handleDropDownZIndex(modalWrap);
1339+
13371340
// очистка массива после закрытия модального окна
13381341
modalWrap.addEventListener('hidden.bs.modal', () => {
13391342
modalContactsArr = [];
@@ -1574,6 +1577,9 @@
15741577
modalContactElement.style.opacity = '1';
15751578
}, 10);
15761579

1580+
// корректировка z-index у/для drop-btn кнопки
1581+
handleDropDownZIndex(modalWrap);
1582+
15771583
// скрытие/сразу li/варианта, как "Телефон" (т.к. в drop-btn отображение по умолчанию)
15781584
if (modalContactDropBtn.textContent === 'Телефон') {
15791585
modalContactItemPhone.style.display = 'none';
@@ -1789,6 +1795,23 @@
17891795
modalContactInput.focus(); // перевод фокуса на соседний инпут (после выбора в выпадающем списке)
17901796
}
17911797

1798+
// ** корректировка z-index у/для drop-btn из строки контакта (при "focus" перекрытие соседнего row-contact инпута)
1799+
function handleDropDownZIndex(modalWrap) {
1800+
const dropDownButtons = modalWrap.querySelectorAll(
1801+
'.modal__body-add-contact-drop-btn'
1802+
);
1803+
1804+
dropDownButtons.forEach((button) => {
1805+
button.addEventListener('focus', () => {
1806+
button.style.zIndex = '5'; // увеличение z-index при "focus"
1807+
});
1808+
1809+
button.addEventListener('blur', () => {
1810+
button.style.zIndex = '3'; // возврат z-index к default значению
1811+
});
1812+
});
1813+
}
1814+
17921815
// ** обновление атрибута/значения "type" у/для модального row-contact инпута (кому возможно, после выбора)
17931816
function updateRowInputType(modalContactInput, contactType) {
17941817
// объект для сопоставления (кому заменять, на какое значение)

0 commit comments

Comments
 (0)