@hypericon/mico 0.5.7 → 0.5.8

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.
@@ -104,7 +104,26 @@ class MenuManager {
104
104
  const asChild = (_b = options === null || options === void 0 ? void 0 : options.asChild) !== null && _b !== void 0 ? _b : menu_settings_1.MENU_SETTINGS.AS_CHILD;
105
105
  if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
106
106
  menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Adding menu as child, event:", ev);
107
- this.directParentEl = ev.target;
107
+ // If the target is an <i> with one of the classes "fas", "far", "fal", "fab", or "fa-*" then
108
+ // we want to add the menu as a child of the parent element, not the icon
109
+ const isIcon = ev.target.tagName === "I" && (ev.target.classList.contains("fas") ||
110
+ ev.target.classList.contains("far") ||
111
+ ev.target.classList.contains("fal") ||
112
+ ev.target.classList.contains("fab") ||
113
+ ev.target.classList.contains("fa"));
114
+ if (isIcon) {
115
+ const parentEl = ev.target.parentElement;
116
+ if (parentEl) {
117
+ this.directParentEl = parentEl;
118
+ }
119
+ else {
120
+ this.directParentEl = ev.target;
121
+ }
122
+ }
123
+ else {
124
+ this.directParentEl = ev.target;
125
+ }
126
+ // this.directParentEl = ev.target;
108
127
  this.directParentWrapperEl = document.createElement("div");
109
128
  this.directParentEl.append(this.directParentWrapperEl);
110
129
  mithril_1.default.render(this.directParentWrapperEl, menuVnode);
@@ -104,7 +104,26 @@ class MenuManager {
104
104
  const asChild = (_b = options === null || options === void 0 ? void 0 : options.asChild) !== null && _b !== void 0 ? _b : menu_settings_1.MENU_SETTINGS.AS_CHILD;
105
105
  if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
106
106
  menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Adding menu as child, event:", ev);
107
- this.directParentEl = ev.target;
107
+ // If the target is an <i> with one of the classes "fas", "far", "fal", "fab", or "fa-*" then
108
+ // we want to add the menu as a child of the parent element, not the icon
109
+ const isIcon = ev.target.tagName === "I" && (ev.target.classList.contains("fas") ||
110
+ ev.target.classList.contains("far") ||
111
+ ev.target.classList.contains("fal") ||
112
+ ev.target.classList.contains("fab") ||
113
+ ev.target.classList.contains("fa"));
114
+ if (isIcon) {
115
+ const parentEl = ev.target.parentElement;
116
+ if (parentEl) {
117
+ this.directParentEl = parentEl;
118
+ }
119
+ else {
120
+ this.directParentEl = ev.target;
121
+ }
122
+ }
123
+ else {
124
+ this.directParentEl = ev.target;
125
+ }
126
+ // this.directParentEl = ev.target;
108
127
  this.directParentWrapperEl = document.createElement("div");
109
128
  this.directParentEl.append(this.directParentWrapperEl);
110
129
  mithril_1.default.render(this.directParentWrapperEl, menuVnode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypericon/mico",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "UI components and utilities with Mithril",
5
5
  "author": "Ed Johnson, Hypericon Ltd",
6
6
  "license": "MIT",