Skip to content

Commit 4f4e9d9

Browse files
committed
fix(vue): add component-specific overlay events
1 parent 4c77460 commit 4f4e9d9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/vue/src/utils/overlays.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { VNode, ComponentOptions } from "vue";
2-
import { defineComponent, h, ref, onMounted } from "vue";
1+
import type { ComponentOptions, VNode } from "vue";
2+
import { defineComponent, h, onMounted, ref } from "vue";
33

44
// TODO(FW-2969): types
55

@@ -147,23 +147,30 @@ export const defineOverlayContainer = <Props extends object>(
147147
const elementRef = ref();
148148

149149
onMounted(() => {
150+
// Convert name from kebab-case to camelCase
151+
const componentName = name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
150152
elementRef.value.addEventListener("ionMount", (ev: Event) => {
151153
emit("ionMount", ev);
154+
emit(componentName + "IonMount", ev);
152155
isOpen.value = true;
153156
});
154157
elementRef.value.addEventListener("willPresent", (ev: Event) => {
155158
emit("willPresent", ev);
159+
emit(componentName + "WillPresent", ev);
156160
isOpen.value = true;
157161
});
158162
elementRef.value.addEventListener("didDismiss", (ev: Event) => {
159163
emit("didDismiss", ev);
164+
emit(componentName + "DidDismiss", ev);
160165
isOpen.value = false;
161166
});
162167
elementRef.value.addEventListener("willDismiss", (ev: Event) => {
163168
emit("willDismiss", ev);
169+
emit(componentName + "WillDismiss", ev);
164170
});
165171
elementRef.value.addEventListener("didPresent", (ev: Event) => {
166172
emit("didPresent", ev);
173+
emit(componentName + "DidPresent", ev);
167174
});
168175
});
169176

0 commit comments

Comments
 (0)