From e8f92eb351b8de15708ca8dfa431c5e5b47f25ec Mon Sep 17 00:00:00 2001 From: Andrew Beng <2418932+andrewbeng89@users.noreply.github.com> Date: Fri, 21 Feb 2025 02:11:54 +0100 Subject: [PATCH] Fix/616 vue custom event listeners (#617) * fix(vue): shift event listener logic from directive to onMounted * fix(vue): remove lower case event naming * tests(vue): for custom event handler and v-model directive * test(vue): include coverage for custom event handler for input component --- example-project/vue-app/src/App.vue | 9 +++++++ .../vue-app/src/components/Input.vue | 16 ++++-------- example-project/vue-app/tests/test.e2e.ts | 7 ++++- packages/vue/src/runtime.ts | 26 ++++++++++--------- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/example-project/vue-app/src/App.vue b/example-project/vue-app/src/App.vue index 548391f2..0f6bead6 100644 --- a/example-project/vue-app/src/App.vue +++ b/example-project/vue-app/src/App.vue @@ -2,6 +2,13 @@ import HelloWorld from './components/HelloWorld.vue' // @ts-ignore import Input from './components/Input.vue' +import { MyComponent } from 'component-library-vue' +import { ref } from 'vue' + +const isClicked = ref(false) +const handleCustomEvent = () => { + isClicked.value = true +} diff --git a/example-project/vue-app/src/components/Input.vue b/example-project/vue-app/src/components/Input.vue index 3a88e54a..3b12afd4 100644 --- a/example-project/vue-app/src/components/Input.vue +++ b/example-project/vue-app/src/components/Input.vue @@ -8,24 +8,18 @@ export default defineComponent({ MyInput, }, setup() { - const inputEvent = ref(''); + const inputValue = ref(''); const changeEvent = ref(''); - const handleInput = (ev) => { - console.log('handleInput', ev.target.value); - inputEvent.value = ev.target.value; - }; - const handleChange = (ev) => { console.log('handleChange', ev.target.value); changeEvent.value = ev.detail.value; }; return { - inputEvent, + inputValue, changeEvent, - handleInput, - handleChange, + handleChange }; }, }); @@ -40,12 +34,12 @@ export default defineComponent({