wj-elements 0.1.221 → 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
  });
@@ -1799,7 +1801,9 @@ class Popup extends WJElement {
1799
1801
  (_c = this.cleanup) == null ? void 0 : _c.call(this);
1800
1802
  this.cleanup = void 0;
1801
1803
  document.removeEventListener("click", this.clickHandler, { capture: true });
1802
- this._restoreContentFromPortal();
1804
+ if (this.portal && this._portaled) {
1805
+ this._restoreContentFromPortal();
1806
+ }
1803
1807
  if (this.hasAttribute("active")) {
1804
1808
  this.removeAttribute("active");
1805
1809
  }
@@ -1819,4 +1823,4 @@ class Popup extends WJElement {
1819
1823
  export {
1820
1824
  Popup as P
1821
1825
  };
1822
- //# sourceMappingURL=popup.element-DmYw9KXv.js.map
1826
+ //# sourceMappingURL=popup.element-CfXgoyrm.js.map