Skip to content

Commit b62524f

Browse files
fix(main.ts): drop-down not clicking properly (#479)
Co-authored-by: Dunsin <[email protected]>
1 parent fb70667 commit b62524f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,7 @@ getRadioButtonSetElement.forEach((radioButton: HTMLInputElement) => {
434434
dropDownElements.forEach((dropDown) => {
435435
// add click event listener to the dropdown parent element
436436
dropDown.addEventListener('click', (e) => {
437-
// keep dropdown open when a subitem is clicked on
438437
e.stopPropagation();
439-
const target = e.target as HTMLElement;
440-
if (!dropDown.children[0].innerHTML.includes(target.outerHTML)) return;
441438

442439
const listElement = dropDown.lastElementChild as HTMLElement;
443440
if (listElement.id === 'showList') {
@@ -456,6 +453,11 @@ dropDownElements.forEach((dropDown) => {
456453

457454
const listElement = dropDown.lastElementChild as HTMLElement;
458455

456+
// Prevent the click event on subitems from propagating to the parent dropdown
457+
listElement.addEventListener('click', (e) => {
458+
e.stopPropagation();
459+
});
460+
459461
// loop through children of dropdown and add event listener to each child
460462
for (let i = 0; i < listElement.children.length; i++) {
461463
const child = listElement.children[i] as HTMLElement;

0 commit comments

Comments
 (0)