Skip to content

Commit

Permalink
Prevent the click event on a solution or hint accordion button inst…
Browse files Browse the repository at this point in the history
…ead of the details.

Add `e.preventDefault()` to the `summary.accordion-button` `click` event
listener instead of preventing all clicks on the `details` tag.

This fixes issue #1178.
  • Loading branch information
drgrice1 committed Jan 15, 2025
1 parent e35b78d commit 4a36b0b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions htdocs/js/Problem/details-accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
if (!collapseEl || !button || !details) return;

const collapse = new bootstrap.Collapse(collapseEl, { toggle: false });
button.addEventListener('click', () => collapse.toggle());
button.addEventListener('click', (e) => {
collapse.toggle();
e.preventDefault();
});

details.addEventListener('click', (e) => e.preventDefault());
collapseEl.addEventListener('show.bs.collapse', () => {
details.open = true;
button.classList.remove('collapsed');
Expand Down

0 comments on commit 4a36b0b

Please sign in to comment.