Modal not working on Firefox
I have a project and the modals are working on Chrome, Opera, Safari. I found a bug report to the livewire repo that matches what we are facing, anyone else having this issue?
Link to github discussion: https://github.com/livewire/livewire/discussions/7746),
GitHub
Too many calls to location or history APIs in a short period of tim...
Livewire version 3.3.5 Laravel version 10.41.0 Which PHP version are you using? PHP 8.3 Steps To Reproduce Using Firefox, when you click several times on one or more links in the side menu (I'm...
11 Replies
Error message:
https://demo.filamentphp.com there are no errors using Firefox on my end..
Is it only specific to modals you’re saying?
Yes, specific to modals
We "fixed" by applying the code below
{{-- Corrigir o problema no Firefox --}}
{{-- Too many calls to location or history APIs in a short period of time. --}}
<script>
const original = window.history.replaceState;
let timer = Date.now();
let timeout = null;
let lastArgs = null;
window.history.replaceState = function (...args) {
const time = Date.now();
if (time - timer < 300) {
lastArgs = args;
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
original.apply(this, lastArgs);
timeout = null;
lastArgs = null;
}, 100);
return;
}
timer = time;
original.apply(this, args);
};
</script>
Kind of weird that its happening with modals specifically. I would have expected the issue to occur just when navigating Resource pages quickly in the UI.
I guess action modals do use query strings though which does use the history api, so I'm not too surprised. I just wish someone with enough Javascript experience and experience with Livewire's frontend code would make a PR given that I kind of gave all of the information regarding the issue in that discussion post..
Also, this does happen... Even in the demo. It's pretty easy to replicate. Just click around on the navigation items quickly.
There is actually an open bug in livewire for this. It’s not specific to filament.
Yes I know. Thats what I was talking about
I replied on the discussion post on Livewire's github repo
Was just commenting for OP
Oh okay sounds good!