mirror of
https://github.com/bitwarden/desktop.git
synced 2024-10-03 04:48:07 +02:00
fixes for initListSectionItemListeners
This commit is contained in:
parent
be389bd7ac
commit
0f7a7c56dc
@ -295,7 +295,7 @@ export default class UtilsService {
|
|||||||
|
|
||||||
initListSectionItemListeners(doc: Document, angular: any) {
|
initListSectionItemListeners(doc: Document, angular: any) {
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
throw new Error('theDoc parameter required');
|
throw new Error('doc parameter required');
|
||||||
}
|
}
|
||||||
|
|
||||||
const sectionItems = doc.querySelectorAll('.list-section-item');
|
const sectionItems = doc.querySelectorAll('.list-section-item');
|
||||||
@ -307,28 +307,25 @@ export default class UtilsService {
|
|||||||
|
|
||||||
const el = e.target as HTMLElement;
|
const el = e.target as HTMLElement;
|
||||||
|
|
||||||
// Labels will already focus the input
|
// Some elements will already focus properly
|
||||||
if (el.tagName != null && el.tagName.toLowerCase() === 'label') {
|
if (el.tagName != null) {
|
||||||
|
switch (el.tagName.toLowerCase()) {
|
||||||
|
case 'label': case 'input': case 'textarea': case 'select':
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const cell = el.closest('.list-section-item');
|
||||||
|
if (!cell) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const textFilter = 'input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"])';
|
const textFilter = 'input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"])';
|
||||||
const text = el.querySelectorAll(textFilter + ',textarea');
|
const text = cell.querySelectorAll(textFilter + ', textarea');
|
||||||
const checkbox = el.querySelectorAll('input[type="checkbox"]');
|
const checkbox = cell.querySelectorAll('input[type="checkbox"]');
|
||||||
const select = el.querySelectorAll('select');
|
const select = cell.querySelectorAll('select');
|
||||||
|
|
||||||
// Return if they click the actual element
|
|
||||||
if (text.length > 0 && el === text[0]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (checkbox.length > 0 && el === checkbox[0]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (select.length > 0 && el === select[0]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (text.length > 0) {
|
if (text.length > 0) {
|
||||||
(text[0] as HTMLElement).focus();
|
(text[0] as HTMLElement).focus();
|
||||||
@ -349,12 +346,22 @@ export default class UtilsService {
|
|||||||
for (const item of sectionFormItems) {
|
for (const item of sectionFormItems) {
|
||||||
item.addEventListener('focus', (e: Event) => {
|
item.addEventListener('focus', (e: Event) => {
|
||||||
const el = e.target as HTMLElement;
|
const el = e.target as HTMLElement;
|
||||||
el.parentElement.classList.add('active');
|
const cell = el.closest('.list-section-item');
|
||||||
|
if (!cell) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell.classList.add('active');
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
item.addEventListener('blur', (e: Event) => {
|
item.addEventListener('blur', (e: Event) => {
|
||||||
const el = e.target as HTMLElement;
|
const el = e.target as HTMLElement;
|
||||||
el.parentElement.classList.remove('active');
|
const cell = el.closest('.list-section-item');
|
||||||
|
if (!cell) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell.classList.remove('active');
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user