-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Warn Before Leaving and Tabs #5370
Comments
Hi @misiekch , Thanks for the report! I can confirm it's happening. For example if we turn However... your code would remove the input entirely from the page. Which... 👀 I don't think is ok. Afaik the input is there in order for the "save and back" functionality to work, after the refresh to be redirected to the same tab. If you remove it with JS... that would stop working. So a more "proper" solution would probably be to remove the input not from the DOM, but from the formData variable. And while we're at it, I believe we can expand the scope, and not only remove function getFormData() {
var form = document.querySelector("main form");
var originalFormData = new FormData(form);
var filteredFormData = new FormData();
// Iterate over each entry in the original FormData
for (let [key, value] of originalFormData.entries()) {
// Add the entry to the new FormData if the key does not start with "_"
if (!key.startsWith('_')) {
filteredFormData.append(key, value);
}
}
return new URLSearchParams(filteredFormData).toString();
} But that doesn't work either 🤦♂️ So... maybe that wasn't the problem here? At least not in Monster? Maybe there's a different input that gets populated with JS? 🤷♂️ I gotta go, but I'll investigate this further and come back with a solution. Thanks for reporting. |
Bug report
What I did
Selecting form tab causes showing warn about unsaved changes.
What I expected to happen
I wanted to leave the form without warning because i hadn't made any real changes.
What happened
Current tab is stored in hidden form field
input[name='_current_tab']
.What I've already tried to fix it
Replacing
getFormData
method inform_content.blade.php
with
Is it a bug in the latest version of Backpack?
After I run
composer update backpack/crud
the bug... is it still there?Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:The text was updated successfully, but these errors were encountered: