New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modal Does Not Pop Up When Using Button Directive When Version is > 2.0.0 #4669
Modal Does Not Pop Up When Using Button Directive When Version is > 2.0.0 #4669
Comments
Could you provide a minimal reproduction of your issue? The docs are working fine for me. Also, how are you importing BootstrapVue into your project? (the full BootstrapVue, or just the ModalPlugin, or the BModal component and VBModal directive?) |
I can't seem to reproduce on a smaller hello world project, but one of the weird things about it not opening was that there were no errors produced so I could not debug what was wrong. I ended up reverting back to 2.0.0-rc.23, but anything newer than that, the modal will not open. |
How are you importing BootstrapVue and registering the components/directives? Without any examples it is hard to provide assistance. One thing to make sure is that your modal ID is all lower case and has no spaces, and starts with a letter. |
I am just importing the modal plugin. Here is how I use it:
|
here's the import:
There's other plugins but those are the two that matter for this example |
package.json:
|
It might be an issue with having both the directive and @click handler on the button. try this instead: <b-button
variant="info"
@click="selectedUser=JSON.parse(JSON.stringify(user));$bvModal.show('edit-user')"
>
<font-awesome-icon icon="edit" />
</b-button> |
That fixed it, thanks! So is that a bug then? Looks like it may because the b-v-modal adds its own click listener: "If the element is anything other than a Can this be fixed, or at least a note in the documentation that you cannot have your own click listener when using b-v-modal? |
We'll have to check to see what the code is doing in the directive (or perhaps it is |
I just created a simple JsFiddle: https://jsfiddle.net/gjphz8w7/ Which appears to be working fine (both the modal opens and the console.log happens. But I did notice that if I try to modify the component state in the It is almost as if the state change is causing the app to re-render, which causes We may need to convert b-button to a full component (instead of a functional component) so that it doesn't destroy the directive when it re-renders. |
Found the issue and it will be fixed in v2.3.0 coming out soon. |
great, thanks! |
I was modifying component state in the click handler so that makes sense. |
Describe the bug
Modal does not pop up when using button directive when version is > 2.0.0.
Steps to reproduce the bug
Create a modal and use the b-v-modal directive as described here:
https://bootstrap-vue.org/docs/components/modal/
Expected behavior
The modal pops open when the button is clicked.
Code
Versions
Libraries:
The text was updated successfully, but these errors were encountered: