Skip to content

Commit

Permalink
fix(main.ts): drop-down not clicking properly (#479)
Browse files Browse the repository at this point in the history
Co-authored-by: Dunsin <78784850+Dun-sin@users.noreply.github.com>
  • Loading branch information
SaketKaswa20 and Dun-sin authored Oct 1, 2023
1 parent fb70667 commit b62524f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,7 @@ getRadioButtonSetElement.forEach((radioButton: HTMLInputElement) => {
dropDownElements.forEach((dropDown) => {
// add click event listener to the dropdown parent element
dropDown.addEventListener('click', (e) => {
// keep dropdown open when a subitem is clicked on
e.stopPropagation();
const target = e.target as HTMLElement;
if (!dropDown.children[0].innerHTML.includes(target.outerHTML)) return;

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

const listElement = dropDown.lastElementChild as HTMLElement;

// Prevent the click event on subitems from propagating to the parent dropdown
listElement.addEventListener('click', (e) => {
e.stopPropagation();
});

// loop through children of dropdown and add event listener to each child
for (let i = 0; i < listElement.children.length; i++) {
const child = listElement.children[i] as HTMLElement;
Expand Down

1 comment on commit b62524f

@vercel
Copy link

@vercel vercel bot commented on b62524f Oct 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.