Skip to content

Commit

Permalink
fixed close collapsible container on item selection (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrik authored Sep 9, 2020
1 parent b17eed7 commit b12d5ce
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/themes/website/scripts/collapsibles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Keys } from "@paperbits/common";

const collapsibleContentSelector = ".collapsible-content";
const paginationSelector = ".pagination";
const collapsibleSelector = ".collapsible";
const collapsibleToggleSelector = "[data-toggle]";
const collapsibleExpandedClass = "expanded";
Expand Down Expand Up @@ -38,6 +40,12 @@ const onActivate = (): void => {

if (target.closest) {
toggleElement = target.closest(collapsibleToggleSelector);
if (!toggleElement && target.nodeName !== "INPUT") {
const pagerElement = target.closest(paginationSelector);
if (!pagerElement) {
toggleElement = target.closest(collapsibleContentSelector)?.parentElement.querySelector(collapsibleToggleSelector);
}
}
}

const exclude = selfAndParents(target);
Expand Down

0 comments on commit b12d5ce

Please sign in to comment.