themesberg / flowbite

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

Tabs lose styles and content when performing Laravel Jetstream / Livewire Actions #733

Open pboese opened 10 months ago

pboese commented 10 months ago

Describe the bug When using interactive tabs (https://flowbite.com/docs/components/tabs/#interactive-tabs) with Laravel Livewire and performing any action that interacts with the backend like wire:click="nothing", the tabs lose their styling and no content is visible. See attached screenshots.

May or may not be related to https://github.com/themesberg/flowbite/issues/721

To Reproduce Steps to reproduce the behaviour:

Livewire component

<?php

namespace App\Livewire\Orders;

use Livewire\Component;

class Tabs extends Component
{
    public function render()
    {
        return view('livewire.orders.tabs');
    }

    public function nothing() {
    }
}

Blade template for the component (code from https://flowbite.com/docs/components/tabs/#interactive-tabs, only added a link that calls the nothing() method)

<div>
    <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">

        <a href="#" class="text-white" wire:click="nothing">Perform empty action (nothing)</a>

        <div class="mb-4 border-b border-gray-200 dark:border-gray-700">
            <ul class="flex flex-wrap -mb-px text-sm font-medium text-center" id="default-tab"
                data-tabs-toggle="#default-tab-content" role="tablist">
                <li class="me-2" role="presentation">
                    <button class="inline-block p-4 border-b-2 rounded-t-lg" id="profile-tab"
                        data-tabs-target="#profile" type="button" role="tab" aria-controls="profile"
                        aria-selected="false">Profile</button>
                </li>
                <li class="me-2" role="presentation">
                    <button
                        class="inline-block p-4 border-b-2 rounded-t-lg hover:text-gray-600 hover:border-gray-300 dark:hover:text-gray-300"
                        id="dashboard-tab" data-tabs-target="#dashboard" type="button" role="tab"
                        aria-controls="dashboard" aria-selected="false">Dashboard</button>
                </li>
            </ul>
        </div>
        <div id="default-tab-content">
            <div class="hidden p-4 rounded-lg bg-gray-50 dark:bg-gray-800" id="profile" role="tabpanel"
                aria-labelledby="profile-tab">
                <p class="text-sm text-gray-500 dark:text-gray-400">This is some placeholder content the <strong
                        class="font-medium text-gray-800 dark:text-white">Profile tab's associated content</strong>.
                    Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps
                    classes to control the content visibility and styling.</p>
            </div>
            <div class="hidden p-4 rounded-lg bg-gray-50 dark:bg-gray-800" id="dashboard" role="tabpanel"
                aria-labelledby="dashboard-tab">
                <p class="text-sm text-gray-500 dark:text-gray-400">This is some placeholder content the <strong
                        class="font-medium text-gray-800 dark:text-white">Dashboard tab's associated content</strong>.
                    Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps
                    classes to control the content visibility and styling.</p>
            </div>
        </div>
    </div>
</div>

Expected behavior Tabs look and work like they did before and show the content.

Screenshots Before click:

Screenshot 2023-11-25 at 11 17 59

After click on

Screenshot 2023-11-25 at 11 18 06

Desktop (please complete the following information):

Thanks a lot for any help and also for the great work - Cheers!

pboese commented 10 months ago

Update: As soon as I click the first tab, the styles and content are back. Only works with the first tab though. So I wrote a very dirty workaround that click()s the first and then the originally active tab...