@cagovweb/state-template 6.3.1-beta8 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var StateTemplateNpmPackageVersion="6.3.1-beta8";
1
+ var StateTemplateNpmPackageVersion="6.3.1";
2
2
  /*!
3
3
  * Bootstrap v5.3.0 (https://getbootstrap.com/)
4
4
  * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
@@ -8702,19 +8702,6 @@ window.addEventListener("load", () => {
8702
8702
 
8703
8703
  const regularHeader = document.querySelector("header");
8704
8704
 
8705
- /**
8706
- * True if child is descendant of the parent
8707
- * @param {HTMLElement} parent
8708
- * @param {HTMLElement} child
8709
- * @returns {boolean}
8710
- */
8711
- const checkParent = (parent, child) =>
8712
- child?.parentElement
8713
- ? child.parentElement === parent
8714
- ? true
8715
- : checkParent(parent, child.parentElement)
8716
- : false;
8717
-
8718
8705
  // reset navigation function
8719
8706
  const NavReset = () => {
8720
8707
  //RESET
@@ -8780,12 +8767,10 @@ window.addEventListener("load", () => {
8780
8767
  // Close menu on focusout (tabbing out) event (if target is outside of mobile menu and ignore if focus target is navToggleBtn button)
8781
8768
  navSearchCont.addEventListener("focusout", e => {
8782
8769
  if (checkIfMobileView()) {
8783
- if (
8784
- !checkParent(
8785
- /** @type {HTMLElement} **/ (e.currentTarget),
8786
- /** @type {HTMLElement} **/ (e.relatedTarget)
8787
- )
8788
- ) {
8770
+ const child = /** @type {Node} **/ (e.relatedTarget);
8771
+ const parent = /** @type {Node} **/ (e.currentTarget);
8772
+
8773
+ if (child && !parent.contains(child)) {
8789
8774
  closeMenu();
8790
8775
  }
8791
8776
  }
@@ -8870,6 +8855,19 @@ window.addEventListener("load", () => {
8870
8855
  }
8871
8856
  };
8872
8857
 
8858
+ // Close mobile nav if click outside of nav
8859
+ regularHeader.addEventListener("mouseup", e => {
8860
+ // if the target of the click isn't the navigation container nor a descendant of the navigation
8861
+ if (checkIfMobileView()) {
8862
+ if (
8863
+ navSearchCont !== e.target &&
8864
+ !navSearchCont?.contains(/**@type {Node} */ (e.target))
8865
+ ) {
8866
+ closeMenu();
8867
+ }
8868
+ }
8869
+ });
8870
+
8873
8871
  // on resize function (hide mobile nav)
8874
8872
  window.addEventListener("resize", mobileCheck);
8875
8873