Fix notification cleanup for Turbo and Livewire navigation

This commit is contained in:
Younes ENNAJI
2026-03-02 02:42:38 +00:00
parent f3d72c88c9
commit e783943933
3 changed files with 12 additions and 3 deletions
@@ -122,6 +122,9 @@ final class HtmlPresenter implements PresenterInterface
const addRenderListener = () => { const addRenderListener = () => {
if (1 === document.querySelectorAll('script.flasher-js').length) { if (1 === document.querySelectorAll('script.flasher-js').length) {
document.addEventListener('flasher:render', render); document.addEventListener('flasher:render', render);
document.addEventListener('turbo:before-cache', () => {
document.querySelectorAll('.fl-wrapper').forEach(el => el.remove());
});
} }
{$livewireListener} {$livewireListener}
@@ -145,7 +148,7 @@ final class HtmlPresenter implements PresenterInterface
return <<<JAVASCRIPT return <<<JAVASCRIPT
document.addEventListener('livewire:navigating', () => { document.addEventListener('livewire:navigating', () => {
document.querySelectorAll('.fl-no-cache').forEach(el => el.remove()); document.querySelectorAll('.fl-wrapper').forEach(el => el.remove());
}); });
JAVASCRIPT; JAVASCRIPT;
} }
@@ -101,6 +101,9 @@ final class HtmlPresenterTest extends TestCase
const addRenderListener = () => { const addRenderListener = () => {
if (1 === document.querySelectorAll('script.flasher-js').length) { if (1 === document.querySelectorAll('script.flasher-js').length) {
document.addEventListener('flasher:render', render); document.addEventListener('flasher:render', render);
document.addEventListener('turbo:before-cache', () => {
document.querySelectorAll('.fl-wrapper').forEach(el => el.remove());
});
} }
{$livewireListener} {$livewireListener}
@@ -235,7 +238,7 @@ final class HtmlPresenterTest extends TestCase
return <<<JAVASCRIPT return <<<JAVASCRIPT
document.addEventListener('livewire:navigating', () => { document.addEventListener('livewire:navigating', () => {
document.querySelectorAll('.fl-no-cache').forEach(el => el.remove()); document.querySelectorAll('.fl-wrapper').forEach(el => el.remove());
}); });
JAVASCRIPT; JAVASCRIPT;
} }
+4 -1
View File
@@ -119,6 +119,9 @@ final class ResponseManagerTest extends TestCase
const addRenderListener = () => { const addRenderListener = () => {
if (1 === document.querySelectorAll('script.flasher-js').length) { if (1 === document.querySelectorAll('script.flasher-js').length) {
document.addEventListener('flasher:render', render); document.addEventListener('flasher:render', render);
document.addEventListener('turbo:before-cache', () => {
document.querySelectorAll('.fl-wrapper').forEach(el => el.remove());
});
} }
{$livewireListener} {$livewireListener}
@@ -162,7 +165,7 @@ final class ResponseManagerTest extends TestCase
return <<<JAVASCRIPT return <<<JAVASCRIPT
document.addEventListener('livewire:navigating', () => { document.addEventListener('livewire:navigating', () => {
document.querySelectorAll('.fl-no-cache').forEach(el => el.remove()); document.querySelectorAll('.fl-wrapper').forEach(el => el.remove());
}); });
JAVASCRIPT; JAVASCRIPT;
} }