I am trying to use unsavedChangesAlerts but unfortunately it doesn't work for my case.
Issues: when navigate to the form (no any changes) - it will trigger an alert about unsaved changes when navigating out of the page. I tried "hack" with calling
$this->form->fill($this->form->getState());
$this->form->fill($this->form->getState());
On the page instance (mount). It helped but then issue still occurred after saving a page. Then I added the same code inside
handleRecordUpdate
handleRecordUpdate
method. Most of the times it worked, but then, there were entities where it didn't help...
so I decided to rewind and look deeper what's going in.
executed on Front-End. $wire.savedDataHash is calculated on backend tho. My form is fairly complex, with few repeaters. Which I believe generates problems. The differences of jsons between client and server are order of items inside repeaters. My assumption: is data types, you see, they work differently on JavaScript and PHP. HashMap on javascript is not a structure that can support sorting. So sequence of properties inside Javascript is kind of random (it's the same for the same object tho), while in PHP it's an order of item has been added.
I think that savedDataHash should be calculated on Front-End side...
Does anyone else have simmilar issue?
Solution
Can you open an issue with a reproduction repo on GitHub please, so we can look into it