Vue-js-modal: Dynamic modal is not shown when using vue-class-component

Created on 14 Oct 2019  路  6Comments  路  Source: euvl/vue-js-modal

I've created a modal component using vue-class-component

<template>
    <div>Hello, world!</div>
</template>

<script lang="ts">
    import Vue from 'vue';
    import Component from 'vue-class-component';

    @Component
    export default class ModalHelloWorld extends Vue {}
</script>

When I try to open it, using dynamic modals, it does not appear:

// some code here
import ModalHelloWorld from '@/components/ModalHelloWorld.vue';

openModal() {
    this.$modal.show(ModalHelloWorld);
}

Of course, I've imported vue-js-modal in this way:

import Vue from 'vue';
import VModal from 'vue-js-modal';

Vue.use(VModal, { dynamic: true, injectModalsContainer: true });
stale

Most helpful comment

UPDATE
Looks like it may just be that current npm package1.3.31 has that as a bug which was already fixed in this commit
As mentioned below, try downloading the latest dist or manually patching your copy or downgrading to 1.3.28 to see if it fixes.
UPDATE

I have the same issue. I think the npm package code is behind the GitHub code.

Un-minifying and diffing npm versions of dist/index.js between versions 1.3.28 and 1.3.31 (ie latest) reveals several changes in how $modal.show works for dynamic components (at least using typescript). src/index.js implies that a new switch statement is supposed to include a 'function' case which allows imported components to render as dynamic:
image

However, the generated 1.3.31 npm bundle dist/index.js (here un-minified) does NOT include the 'function' case:
image

The code here is correct:
image

Downloading above and replacing in node_modules or manually adding "case 'function':" to dist/index.js fixes it for me.

All 6 comments

I have a similar problem. Looks like the CSS is not being applied correctly, and the dynamically injected model has display: none and opacity: 0:

image

UPDATE
Looks like it may just be that current npm package1.3.31 has that as a bug which was already fixed in this commit
As mentioned below, try downloading the latest dist or manually patching your copy or downgrading to 1.3.28 to see if it fixes.
UPDATE

I have the same issue. I think the npm package code is behind the GitHub code.

Un-minifying and diffing npm versions of dist/index.js between versions 1.3.28 and 1.3.31 (ie latest) reveals several changes in how $modal.show works for dynamic components (at least using typescript). src/index.js implies that a new switch statement is supposed to include a 'function' case which allows imported components to render as dynamic:
image

However, the generated 1.3.31 npm bundle dist/index.js (here un-minified) does NOT include the 'function' case:
image

The code here is correct:
image

Downloading above and replacing in node_modules or manually adding "case 'function':" to dist/index.js fixes it for me.

@euvl when will news version?

Temp fix for peoples who can't download and replace code in node_modules.
Just change version to this
"vue-js-modal": "euvl/vue-js-modal#master",
But in future when new version will on npm, replace back to need version.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ar53n picture ar53n  路  4Comments

smholsen picture smholsen  路  4Comments

chris-rowe picture chris-rowe  路  4Comments

vesper8 picture vesper8  路  3Comments

dland512 picture dland512  路  4Comments