themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS
https://flowbite.com
MIT License
7.35k stars 711 forks source link

Dropdown not working with Laravel Livewire 3 wire:navigate #691

Closed nasirkhan closed 8 months ago

nasirkhan commented 8 months ago

Describe the bug I am using Flowbite in a number of Laravel projects. In a recent project, I started to use Livewire 3 and its wire:navigate.

The dropdown menu works only after a full page refresh but not for the wire:navigate. I would like to mention that the menu area remains the same for regular blade pages and livewire full-page components.

To Reproduce Steps to reproduce the behavior:

  1. Create Livewire 3 full page component https://livewire.laravel.com/docs/components#full-page-components. Implement wire:navigate for pages.
  2. Create a dropdown menu.
  3. Change the page using menu,
  4. now click on the dropdown menu item again and see if the dropdown items appears or not

Expected behavior The drop-down menu should appear each time I click the related parent menu item.

reasecret commented 8 months ago

I'm facing same issue right now and looks like I found solution: https://www.youtube.com/watch?v=gkDq2E6g0F0

Just add this to app.js file:

document.addEventListener('livewire:navigated', () => { 
    initFlowbite();
})
nasirkhan commented 8 months ago

@reasecret thanks. This solves the issue.