Navigate progress bar slips under positioned elements while it fades out
Livewire version
v4.4.6
Laravel version
v13.33.0
PHP version
8.5.10
Browser and operating system
Chrome on macOS
Describe the issue you're experiencing
When a wire:navigate visit finishes, the progress bar fades out. During that fade, any positioned element with a z-index (a fixed or sticky sidebar, a fixed header) paints over the bar. So the bar vanishes over that element first, and for a few frames it seems to start at the element's edge.
The cause is in the styles js/plugins/navigate/bar.js injects. NProgress fades by setting opacity on #nprogress. An opacity below 1 makes #nprogress a stacking context. The bar's z-index: 1031 then only ranks it inside #nprogress, and #nprogress has no z-index of its own. So the whole bar paints at the level of the page's other non-positioned content, under anything with z-index of 1 or more.
Code snippets to reproduce the issue
// routes/web.php
Route::livewire('/one', 'pages::one');
Route::livewire('/two', 'pages::two');{{-- resources/views/pages/⚡one.blade.php --}}
<?php
use Livewire\Component;
new class extends Component {};
?>
<div>
<aside style="position: fixed; top: 0; left: 0; z-index: 20; width: 256px; height: 100vh; background: #eee"></aside>
<a href="/two" wire:navigate style="margin-left: 300px">Go to two</a>
</div>{{-- resources/views/pages/⚡two.blade.php --}}
<?php
use Livewire\Component;
new class extends Component {
public function mount(): void
{
usleep(600000); // long enough for the bar to show (it waits 150ms)
}
};
?>
<div>
<aside style="position: fixed; top: 0; left: 0; z-index: 20; width: 256px; height: 100vh; background: #eee"></aside>
<div style="margin-left: 300px">On two</div>
</div>Click "Go to two" and watch the bar as it fades out: the part over the grey aside disappears first, so the bar appears to begin at x=256.
Screenshots/screen recordings
Probing the top element at (50, 1), over the aside, on every animation frame while #nprogress exists (element on top @ #nprogress opacity):
before the fade: bar@1
during the fade: [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]With the fix below, every one of those frames reports bar.
How do you expect it to work?
The whole bar stays on top while it fades. Giving the wrapper its own z-index does it:
#nprogress {
pointer-events: none;
position: relative;
z-index: 1031;
}I'll open a PR with this change and a browser test.
Please confirm (incomplete submissions will not be addressed)
- I have provided easy and step-by-step instructions to reproduce the bug.
- I have provided code samples as text and NOT images.
- I understand my bug report will be removed if I haven't met the criteria above.
Source: livewire/livewire