© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Sandeep

Issue: Disappearing Button on Dashboard Stat Widget

I'm trying to add a button labeled "Fix Errors" to a Stat widget on the dashboard. The goal is to have this button trigger a public function when clicked, which then executes a command to fix the errors. However, I'm encountering an issue where the button disappears after it is clicked, even though the function is called correctly.

Can someone help me figure out why the button is disappearing and how to prevent it? Below is the code, I'm using and I've also attached the code php file and a screenshot for reference.

protected function getStats(): array
    {

        $errorCount = Product::where('is_error', true)->count();

        return [
            Stat::make('Product Sync Errors', $errorCount)
                ->description('Number of products with sync errors')
                ->color('danger')
                ->extraAttributes([
                    'class' => 'relative cursor-pointer',
                    'x-data' => '{}',
                    'role' => 'button',
                    'tabindex' => '0',
                    'aria-label' => 'Filter Product Sync Errors',
                    'x-init' => "
            let button = document.createElement('button');
            button.className = 'absolute top-0 right-0 mt-2 mr-2 px-2 py-1 text-sm text-white bg-blue-500 rounded hover:bg-blue-600';
            button.setAttribute('aria-label', 'Fix Errors');
            button.innerText = 'Fix Errors';
            button.setAttribute('wire:click', `\$dispatch('setStatusFilter',{ filter: ['processed', {$errorCount}]})`);
            \$el.appendChild(button);
        ",
                ]),


                ];
    }
protected function getStats(): array
    {

        $errorCount = Product::where('is_error', true)->count();

        return [
            Stat::make('Product Sync Errors', $errorCount)
                ->description('Number of products with sync errors')
                ->color('danger')
                ->extraAttributes([
                    'class' => 'relative cursor-pointer',
                    'x-data' => '{}',
                    'role' => 'button',
                    'tabindex' => '0',
                    'aria-label' => 'Filter Product Sync Errors',
                    'x-init' => "
            let button = document.createElement('button');
            button.className = 'absolute top-0 right-0 mt-2 mr-2 px-2 py-1 text-sm text-white bg-blue-500 rounded hover:bg-blue-600';
            button.setAttribute('aria-label', 'Fix Errors');
            button.innerText = 'Fix Errors';
            button.setAttribute('wire:click', `\$dispatch('setStatusFilter',{ filter: ['processed', {$errorCount}]})`);
            \$el.appendChild(button);
        ",
                ]),


                ];
    }
image.png
StatsOverview.php2.22KB
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

how to set grid stat widget on dashboard
FilamentFFilament / ❓┊help
3y ago
widget stat
FilamentFFilament / ❓┊help
2y ago
Widget Stat
FilamentFFilament / ❓┊help
3y ago
Hide widget on dashboard
FilamentFFilament / ❓┊help
3y ago