wj-elements 0.1.220 → 0.1.222

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.
@@ -52,11 +52,16 @@ export default class Dropdown extends WJElement {
52
52
  */
53
53
  draw(): DocumentFragment;
54
54
  anchorSlot: HTMLSlotElement;
55
- popupHideCallback: (e: any) => void;
56
55
  /**
57
56
  * Adds event listeners for the mouseenter and mouseleave events.
58
57
  */
59
58
  afterDraw(): void;
59
+ popupHideCallback: (e: any) => void;
60
+ /**
61
+ * Handles delegated clicks from inside the popup and closes the dropdown when a leaf menu item is selected.
62
+ * This works even when the menu is portaled, because we rely on the composed path.
63
+ */
64
+ onMenuItemClick: (e: any) => void;
60
65
  /**
61
66
  * @summary Toggles the dropdown element between active and inactive states.
62
67
  * Calls the `onOpen` method if the element is currently inactive,
@@ -81,4 +86,5 @@ export default class Dropdown extends WJElement {
81
86
  beforeClose: () => void;
82
87
  afterClose: () => void;
83
88
  onClose: () => void;
89
+ #private;
84
90
  }
@@ -1385,7 +1385,9 @@ class Popup extends WJElement {
1385
1385
  this.showHide();
1386
1386
  });
1387
1387
  __publicField(this, "clickHandler", (e) => {
1388
- const path = e.composedPath();
1388
+ const path = typeof e.composedPath === "function" ? e.composedPath() : [];
1389
+ const isMenuClick = path.some((n) => n && (n.tagName === "WJE-MENU-ITEM" || n.tagName === "WJE-MENU" || n.tagName === "WJE-DROPDOWN"));
1390
+ if (isMenuClick) return;
1389
1391
  const inside = path.includes(this) || this.floatingEl && path.includes(this.floatingEl);
1390
1392
  if (!inside && this.hasAttribute("active")) this.hide(true);
1391
1393
  });
@@ -1510,7 +1512,6 @@ class Popup extends WJElement {
1510
1512
  afterDraw() {
1511
1513
  this.setAnchor();
1512
1514
  this.addEventListener("wje-popup:content-ready", () => {
1513
- debugger;
1514
1515
  this.markContentReady();
1515
1516
  }, { once: true });
1516
1517
  if (this.hasAttribute("active")) this.show(false);
@@ -1763,7 +1764,6 @@ class Popup extends WJElement {
1763
1764
  */
1764
1765
  show(dispatchEvent = true) {
1765
1766
  var _a, _b, _c, _d, _e, _f, _g, _h;
1766
- debugger;
1767
1767
  if (this.portal) {
1768
1768
  this._mountContentToPortal();
1769
1769
  }
@@ -1801,7 +1801,9 @@ class Popup extends WJElement {
1801
1801
  (_c = this.cleanup) == null ? void 0 : _c.call(this);
1802
1802
  this.cleanup = void 0;
1803
1803
  document.removeEventListener("click", this.clickHandler, { capture: true });
1804
- this._restoreContentFromPortal();
1804
+ if (this.portal && this._portaled) {
1805
+ this._restoreContentFromPortal();
1806
+ }
1805
1807
  if (this.hasAttribute("active")) {
1806
1808
  this.removeAttribute("active");
1807
1809
  }
@@ -1821,4 +1823,4 @@ class Popup extends WJElement {
1821
1823
  export {
1822
1824
  Popup as P
1823
1825
  };
1824
- //# sourceMappingURL=popup.element-B0Lm42bh.js.map
1826
+ //# sourceMappingURL=popup.element-CfXgoyrm.js.map