tabuna / breadcrumbs

Laravel Breadcrumbs - An easy way to add breadcrumbs to your @Laravel app.
https://github.com/tabuna/breadcrumbs
MIT License
339 stars 20 forks source link

Using Livewire routes macro it push the breadcrumb three times #9

Closed masterix21 closed 3 years ago

masterix21 commented 4 years ago

Using the following code in the web.php file:

Route::livewire('dashboard', 'dashboard')->name('home')
        ->breadcrumbs(fn (Trail $trail) => $trail->push("Dashboard", route("home")) && \Illuminate\Support\Facades\Log::debug('Dashboard pushed'));

You'll get the follow logs output:

[2020-09-01 18:25:53] local.DEBUG: Dashboard pushed  
[2020-09-01 18:25:53] local.DEBUG: Dashboard pushed  
[2020-09-01 18:25:53] local.DEBUG: Dashboard pushed  

It means that the breadcrumb pushed three times, and the title will be wrong.

tabuna commented 4 years ago

Hey @masterix21. Thank you for bringing this to your attention.

I've added a test that verifies this example without using Livewire, and this example only runs once. Maybe the problem with this behavior is not in this package?

I also have a few questions:

tabuna commented 3 years ago

Hi, I tried to reproduce the problem on the second livewire version. But with the code that was recommended.

Route::get('dashboard', \App\Http\Livewire\Counter::class)->name('home')
    ->breadcrumbs(fn (Trail $trail) => $trail->push("Dashboard", route("home")) && \Illuminate\Support\Facades\Log::debug('Dashboard pushed'));

This code also works only once.

masterix21 commented 3 years ago

Using Livewire 2, yes, it works once.

tabuna commented 3 years ago

Hey. That's great, then no problem.