diff --git a/src/Features/AutoInjectRappasoftAssets.php b/src/Features/AutoInjectRappasoftAssets.php index 73e2c5e12..0b54aa6eb 100644 --- a/src/Features/AutoInjectRappasoftAssets.php +++ b/src/Features/AutoInjectRappasoftAssets.php @@ -4,6 +4,7 @@ use Illuminate\Foundation\Http\Events\RequestHandled; use Livewire\ComponentHook; +use Rappasoft\LaravelLivewireTables\DataTableComponent; use Rappasoft\LaravelLivewireTables\Mechanisms\RappasoftFrontendAssets; use function Livewire\on; @@ -36,6 +37,10 @@ public static function provide(): void return; } + if (! static::$hasRenderedAComponentThisRequest) { + return; + } + // If All Scripts Have Been Rendered - Return if ( ( @@ -73,7 +78,9 @@ public static function provide(): void public function dehydrate(): void { - static::$hasRenderedAComponentThisRequest = true; + if ($this->component instanceof DataTableComponent){ + static::$hasRenderedAComponentThisRequest = true; + } } public static function injectAssets(mixed $html): string