@rogieking/figui3 8.9.8 → 8.9.9

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.
package/fig.js CHANGED
@@ -18796,7 +18796,6 @@ class FigMenu extends HTMLElement {
18796
18796
  #boundPopupClick;
18797
18797
  #boundMenuKeydown;
18798
18798
  #boundPopupClose;
18799
- #boundPopupToggle;
18800
18799
  #boundSyncOverflow = this.#syncOverflow.bind(this);
18801
18800
  #focusedIndex = -1;
18802
18801
 
@@ -18811,7 +18810,6 @@ class FigMenu extends HTMLElement {
18811
18810
  this.#boundPopupClick = this.#handlePopupClick.bind(this);
18812
18811
  this.#boundMenuKeydown = this.#handleMenuKeydown.bind(this);
18813
18812
  this.#boundPopupClose = this.#handlePopupClose.bind(this);
18814
- this.#boundPopupToggle = this.#handlePopupToggle.bind(this);
18815
18813
  }
18816
18814
 
18817
18815
  get value() {
@@ -18859,12 +18857,10 @@ class FigMenu extends HTMLElement {
18859
18857
  }
18860
18858
  if (this.#popup) {
18861
18859
  this.#popup.removeEventListener("close", this.#boundPopupClose);
18862
- this.#popup.removeEventListener("toggle", this.#boundPopupToggle);
18863
- this.#popup.open = false;
18864
18860
  const items = Array.from(
18865
18861
  this.#panel?.querySelectorAll(FIG_MENU_CHILD_SELECTOR) ?? [],
18866
18862
  );
18867
- for (const item of items) this.append(item);
18863
+ for (const item of items) this.insertBefore(item, this.#popup);
18868
18864
  this.#popup.remove();
18869
18865
  this.#popup = null;
18870
18866
  this.#panel = null;
@@ -18915,16 +18911,17 @@ class FigMenu extends HTMLElement {
18915
18911
  }
18916
18912
 
18917
18913
  #createPopup() {
18918
- const supportsPopover =
18919
- typeof HTMLElement !== "undefined" &&
18920
- "popover" in HTMLElement.prototype;
18921
18914
  this.#popup = document.createElement("dialog", { is: "fig-popup" });
18922
18915
  this.#popup.setAttribute("is", "fig-popup");
18923
18916
  this.#popup.classList.add("fig-menu-popup");
18924
18917
  this.#popup.setAttribute("theme", "menu");
18925
18918
  this.#popup.setAttribute("role", "menu");
18926
18919
  this.#popup.setAttribute("id", this.#popup.getAttribute("id") || figUniqueId());
18927
- if (supportsPopover) this.#popup.setAttribute("popover", "manual");
18920
+ // Top-layer via popover so the menu escapes ancestor filter/contain
18921
+ // (nested fig-popup with variant="popover" creates a fixed containing block).
18922
+ if ("popover" in HTMLElement.prototype) {
18923
+ this.#popup.setAttribute("popover", "manual");
18924
+ }
18928
18925
 
18929
18926
  const position = this.getAttribute("position") || "bottom left";
18930
18927
  this.#popup.setAttribute("position", position);
@@ -18944,26 +18941,7 @@ class FigMenu extends HTMLElement {
18944
18941
  this.#panel.setAttribute("role", "presentation");
18945
18942
  this.#popup.appendChild(this.#panel);
18946
18943
  this.#popup.addEventListener("close", this.#boundPopupClose);
18947
- this.#popup.addEventListener("toggle", this.#boundPopupToggle);
18948
-
18949
- if (supportsPopover) {
18950
- (figGetOverlayRoot() ?? document.body).append(this.#popup);
18951
- return;
18952
- }
18953
-
18954
- const openDialogs = [];
18955
- let ancestor = this.parentElement;
18956
- while (ancestor) {
18957
- if (ancestor instanceof HTMLDialogElement && ancestor.open) {
18958
- openDialogs.push(ancestor);
18959
- }
18960
- ancestor = ancestor.parentElement;
18961
- }
18962
- if (openDialogs.length === 1) {
18963
- openDialogs[0].append(this.#popup);
18964
- } else {
18965
- (figGetOverlayRoot() ?? document.body).append(this.#popup);
18966
- }
18944
+ this.appendChild(this.#popup);
18967
18945
  }
18968
18946
 
18969
18947
  #moveItemsToPopup() {
@@ -19142,7 +19120,7 @@ class FigMenu extends HTMLElement {
19142
19120
  if (this.#usesContextMenuTrigger()) return;
19143
19121
  if (this.#isDisabled()) return;
19144
19122
  e.stopPropagation();
19145
- const popupShowing = this.#isPopupShowing();
19123
+ const popupShowing = this.#popup?.matches?.(":open") ?? false;
19146
19124
  if (this.open && !popupShowing) {
19147
19125
  this.removeAttribute("open");
19148
19126
  }
@@ -19205,7 +19183,7 @@ class FigMenu extends HTMLElement {
19205
19183
  if (this.#isDisabled()) return;
19206
19184
  if (e.currentTarget === document && e.key !== "Escape") return;
19207
19185
  if (e.currentTarget === this && this.#popup?.contains(e.target)) return;
19208
- if (!this.open || !this.#isPopupShowing()) {
19186
+ if (!this.open || !this.#popup?.matches?.(":open")) {
19209
19187
  if (
19210
19188
  this.#trigger?.contains(e.target) &&
19211
19189
  (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ")
@@ -19275,17 +19253,6 @@ class FigMenu extends HTMLElement {
19275
19253
  this.#focusedIndex = -1;
19276
19254
  }
19277
19255
 
19278
- #handlePopupToggle(event) {
19279
- if (event.newState === "closed") this.#handlePopupClose();
19280
- }
19281
-
19282
- #isPopupShowing() {
19283
- return Boolean(
19284
- this.#popup?.matches?.(":open") ||
19285
- this.#popup?.matches?.(":popover-open"),
19286
- );
19287
- }
19288
-
19289
19256
  #selectItem(item) {
19290
19257
  const value = item.getAttribute("value") || item.textContent.trim();
19291
19258
  this.setAttribute("value", value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "8.9.8",
3
+ "version": "8.9.9",
4
4
  "description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
5
5
  "author": "Rogie King",
6
6
  "license": "MIT",