@hypericon/mico 0.5.6 → 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.
|
@@ -102,8 +102,28 @@ class MenuManager {
|
|
|
102
102
|
}
|
|
103
103
|
// m.render(this.containerEl, menuVnode);
|
|
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
|
-
if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.
|
|
106
|
-
|
|
105
|
+
if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
|
|
106
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Adding menu as child, event:", ev);
|
|
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;
|
|
107
127
|
this.directParentWrapperEl = document.createElement("div");
|
|
108
128
|
this.directParentEl.append(this.directParentWrapperEl);
|
|
109
129
|
mithril_1.default.render(this.directParentWrapperEl, menuVnode);
|
|
@@ -102,8 +102,28 @@ class MenuManager {
|
|
|
102
102
|
}
|
|
103
103
|
// m.render(this.containerEl, menuVnode);
|
|
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
|
-
if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.
|
|
106
|
-
|
|
105
|
+
if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
|
|
106
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Adding menu as child, event:", ev);
|
|
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;
|
|
107
127
|
this.directParentWrapperEl = document.createElement("div");
|
|
108
128
|
this.directParentEl.append(this.directParentWrapperEl);
|
|
109
129
|
mithril_1.default.render(this.directParentWrapperEl, menuVnode);
|