livewire-bootstrap-modal icon indicating copy to clipboard operation
livewire-bootstrap-modal copied to clipboard

Not working with wire:navigate

Open QualityCodeSA opened this issue 1 year ago • 12 comments
trafficstars

Bootstrapt modal working fine when first time open page with refresh but in livewire 3 not working when come back from other page (usinf wire:navigate) and open modal

QualityCodeSA avatar Jan 16 '24 07:01 QualityCodeSA

yes, I know some problem and I am working hard on it.

aliqasemzadeh avatar Jan 17 '24 02:01 aliqasemzadeh

yes, I know some problem and I am working hard on it.

Thank you brother. Update me once finish so I will apply changes

QualityCodeSA avatar Jan 17 '24 04:01 QualityCodeSA

Check note and update. I hope this update help me and then let me know.

aliqasemzadeh avatar Jan 17 '24 05:01 aliqasemzadeh

@aliqasemzadeh any update regarding not working with wire:navigate ?

QualityCodeSA avatar Jan 18 '24 06:01 QualityCodeSA

@QualityCodeSA No it doesn't work. I think we need trait to dispatch modals to solve this problem.

aliqasemzadeh avatar Jan 19 '24 01:01 aliqasemzadeh

@QualityCodeSA Trait doesn't work.

aliqasemzadeh avatar Jan 22 '24 08:01 aliqasemzadeh

@aliqasemzadeh any possibility to work or not?

QualityCodeSA avatar Jan 26 '24 10:01 QualityCodeSA

@QualityCodeSA It looks like there is no solution a the moment.

aliqasemzadeh avatar Jan 27 '24 10:01 aliqasemzadeh

I think we need to persist the livewire modal? @persist('modals')

<livewire-modals

@endpersist @aliqasemzadeh @QualityCodeSA

mozhuilungdsuo avatar Jan 27 '24 10:01 mozhuilungdsuo

@mozhuilungdsuo Please give us example.

aliqasemzadeh avatar Jan 27 '24 10:01 aliqasemzadeh

as per the documentation a <a href="/users" wire:navigate>Users</a> requests the page in the background and replaces the current page. So the livewire modal component ie <livewire:modals/> we put in the app layout view would show the old livewire component and since we added a new livewire component itll give issue ( thats what i assume). so as per the documentation herehttps://livewire.laravel.com/docs/navigate

we should be keeping this in the app layout view. @persist('player') <livewire:modals/> @endpersist I maybe wrong but this should ideally fix it.

mozhuilungdsuo avatar Jan 27 '24 11:01 mozhuilungdsuo

@mozhuilungdsuo yeah persist works, another issue i found is modal-backdrop not being created so the solution i found is to add event listener for livewire:navigated and dispose the old modal document.addEventListener("livewire:navigated", () => { let modal = Modal.getInstance(modalsElement); if (modal) { modal.dispose(); } });

r7zq avatar Apr 25 '24 13:04 r7zq