Skip to content

Commit

Permalink
feat(#106): emit click event (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher authored Oct 23, 2023
1 parent c047bd0 commit 7b59193
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/Collapsible.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'data-collapsible-collapsed': collapsed
}"
>
<div data-collapsible-trigger="">
<div data-collapsible-trigger="" @click="onClick">
<slot name="trigger">{{ trigger }}</slot>
</div>
<div data-collapsible-panel="">
Expand All @@ -29,19 +29,32 @@ export default {
mounted() {
try {
// If the component has been mounted and $el is available
if (this.$el) {
// Delete the cached module for collapsible
delete require.cache[require.resolve('civictheme/components/00-base/collapsible/collapsible')]
// Require the collapsible module again
require('civictheme/components/00-base/collapsible/collapsible')
}
}
catch(e) {
// Output an error message to the console if there is an issue
// eslint-disable-next-line
console.error(e)
}
},
// Delete require cache for collapsible component
beforeDestroy() {
delete require.cache[require.resolve('civictheme/components/00-base/collapsible/collapsible')]
},
methods: {
onClick() {
// Emit the 'click' event to notify parent components that the trigger has been clicked.
this.$emit('click')
}
}
}
</script>

0 comments on commit 7b59193

Please sign in to comment.