vue-form-wizard icon indicating copy to clipboard operation
vue-form-wizard copied to clipboard

Rearranged tabs when re-opening form wizard in bootstrap-vue modal window

Open headkit opened this issue 5 years ago • 15 comments

I am using the Form Wizard together with Vue Form Generator inside an Bootstrap-Vue modal popup window. When first initialized everything seems to be fine, but when I close the modal and reopen it the tabs have changed their ordering. The last tab is now the first one.

Any idea why this happens?

headkit avatar Jan 05 '20 21:01 headkit

I have the same issue, did you solve it?

Hadas97 avatar Jan 08 '20 19:01 Hadas97

not yet, still on it. what's your scenario? I was trying to reset the wizard with

this.$refs.wizard.reset();

on hideModal() but with no effect at all.

headkit avatar Jan 08 '20 20:01 headkit

I have the same problem, you found how to fix it?

cesarureno avatar Jan 21 '20 18:01 cesarureno

I did seem to get this fixed using refs. On the modal I used @hidden="onModalHidden" then in the formwizard I set ref called "travelwizard" as this is for a custom travel form. Then the event looks like this: onModalHidden: function(args) { vm.ref['travelwizard'].reset() }, vm is actually 'this' but I use vm set to 'this' on mounted to ensure a proper handle on some events

danwalker-caci avatar Jan 29 '20 16:01 danwalker-caci

So, I tried a different approach and wrapped my form-wizard with vue's keep-alive and this really seems to help maintain order and so far it works great!

danwalker-caci avatar Jan 30 '20 16:01 danwalker-caci

I tried version Bootstrap-Vue 2.7.0 and this problem appeared. I tried version 2.0.0-rc.1, it works well. I think the problem is with the Bootstrap-Vue version. The last safe version for vue-form-wizard inside modal is 2.0.0-rc.19 (I'm using this) IDK what happened with the newest version of Bootstrap-Vue.

yusrenaltair avatar Mar 18 '20 01:03 yusrenaltair

Modals are portalled (and lazy). Refs are only available when the modal is open (the content is only rendered when the modal is open).

To disable portaling of the modal, set the static prop on <b-modal>.

tmorehouse avatar Mar 18 '20 03:03 tmorehouse

The cause of the issue stems from this line:

https://github.com/BinarCode/vue-form-wizard/blob/cfc12ce1dcee2487cba41386415c3660259429fd/src/components/FormWizard.vue#L238

Vue 2.6 caches slot functions. All slots are now functions and this.$slots[name] may return stale vNodes (we ran into this issue with b-tabs)

One needs to run this.$scopedSlots[name](scope) to get a fresh copy of vNodes.

tmorehouse avatar Mar 18 '20 03:03 tmorehouse

So, I tried a different approach and wrapped my form-wizard with vue's keep-alive and this really seems to help maintain order and so far it works great!

show your code

xerox-xeon avatar Dec 15 '20 16:12 xerox-xeon

The cause of the issue stems from this line:

https://github.com/BinarCode/vue-form-wizard/blob/cfc12ce1dcee2487cba41386415c3660259429fd/src/components/FormWizard.vue#L238

Vue 2.6 caches slot functions. All slots are now functions and this.$slots[name] may return stale vNodes (we ran into this issue with b-tabs)

One needs to run this.$scopedSlots[name](scope) to get a fresh copy of vNodes.

Hi @tmorehouse , what should name & scope be in this instance. I'm not sure I'm following

jongbonga avatar Feb 03 '21 16:02 jongbonga

Modals are portalled (and lazy). Refs are only available when the modal is open (the content is only rendered when the modal is open).

To disable portaling of the modal, set the static prop on <b-modal>.

static seems to solve the problem, but it causes modal to be appended to the parent element. If you have a modal declared inside a div, rather than the body, the modal overlays only it.

ggondim avatar Feb 04 '21 18:02 ggondim

Modals are portalled (and lazy). Refs are only available when the modal is open (the content is only rendered when the modal is open). To disable portaling of the modal, set the static prop on <b-modal>.

static seems to solve the problem, but it causes modal to be appended to the parent element. If you have a modal declared inside a div, rather than the body, the modal overlays only it.

Noticed that too, I'm trying to avoid the static way

jongbonga avatar Feb 04 '21 18:02 jongbonga

So, I tried a different approach and wrapped my form-wizard with vue's keep-alive and this really seems to help maintain order and so far it works great!

Tried to wrap both around <form-wizard> and <b-modal>. None of them worked.

But wrapping around the tabs seems to work:

image

ggondim avatar Feb 04 '21 18:02 ggondim

So, I tried a different approach and wrapped my form-wizard with vue's keep-alive and this really seems to help maintain order and so far it works great!

Tried to wrap both around <form-wizard> and <b-modal>. None of them worked.

But wrapping around the tabs seems to work:

image

I was wrong. It removed the other tabs. image

<keep-alive> around each tab content causes the tabs to be ordered different than DOM declarations:

image

image

Then, <keep-alive> didn't work at all.

ggondim avatar Feb 04 '21 18:02 ggondim

The cause of the issue stems from this line: https://github.com/BinarCode/vue-form-wizard/blob/cfc12ce1dcee2487cba41386415c3660259429fd/src/components/FormWizard.vue#L238

Vue 2.6 caches slot functions. All slots are now functions and this.$slots[name] may return stale vNodes (we ran into this issue with b-tabs) One needs to run this.$scopedSlots[name](scope) to get a fresh copy of vNodes.

Hi @tmorehouse , what should name & scope be in this instance. I'm not sure I'm following

How did you go about fixing this?

LRJasmine avatar Feb 01 '22 18:02 LRJasmine