Skip to content

Commit

Permalink
fix: resolve issue remounting civictheme javascript (#96)
Browse files Browse the repository at this point in the history
* chore(#9): improve node library setup/teardown

* chore(#93): improve node library setup/teardown

* chore: fix lint issues
  • Loading branch information
Decipher authored Aug 1, 2023
1 parent dd263f8 commit fba3b0d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
19 changes: 15 additions & 4 deletions src/components/MenuItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,27 @@ export default {
isFlyout: ({ type }) => type === 'flyout',
},
created() {
// @TODO - Do this elsewhere?
mounted() {
try {
if (process.client && this.isCollapsible) require('civictheme/components/00-base/collapsible/collapsible')
if (process.client && this.isFlyout) require('civictheme/components/00-base/flyout/flyout')
if (this.isCollapsible) {
delete require.cache[require.resolve('civictheme/components/00-base/collapsible/collapsible')]
require('civictheme/components/00-base/collapsible/collapsible')
}
if (this.isFlyout) {
delete require.cache[require.resolve('civictheme/components/00-base/flyout/flyout')]
require('civictheme/components/00-base/flyout/flyout')
}
}
catch(e) {
// eslint-disable-next-line
console.error(e)
}
},
beforeDestroy() {
if (this.isCollapsible) delete require.cache[require.resolve('civictheme/components/00-base/collapsible/collapsible')]
if (this.isFlyout) delete require.cache[require.resolve('civictheme/components/00-base/flyout/flyout')]
}
}
</script>
12 changes: 10 additions & 2 deletions src/components/Popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<a
:class="`ct-link ${themeClass} ct-popover__link`"
:data-collapsible-trigger="true"
@click="$emit('trigger')"
>
<slot name="trigger">
{{ trigger }}
Expand Down Expand Up @@ -42,14 +43,21 @@ export default {
}
},
created() {
mounted() {
try {
if (process.client) require('civictheme/components/00-base/collapsible/collapsible')
if (this.$el) {
delete require.cache[require.resolve('civictheme/components/00-base/collapsible/collapsible')]
require('civictheme/components/00-base/collapsible/collapsible')
}
}
catch(e) {
// eslint-disable-next-line
console.error(e)
}
},
beforeDestroy() {
delete require.cache[require.resolve('civictheme/components/00-base/collapsible/collapsible')]
}
}
</script>

0 comments on commit fba3b0d

Please sign in to comment.