Skip to content
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

Since WP 6.6+, navigating away from profile page prompts “Leave site?” dialog (despite no changes) #102

Open
MadtownLems opened this issue Oct 3, 2024 · 1 comment

Comments

@MadtownLems
Copy link

Hi there! I already posted on the wp.org forums, but not sure which you prefer so I'm duplicating here (https://wordpress.org/support/topic/since-wp-6-6-navigating-away-from-profile-page-prompts-leave-site-dialog/)

Since upgrading to WP 6.6.2 (from 6.5.x), we’ve noticed that whenever a user navigates away from their profile page, they are shown the “Leave site? Changes you made may not be saved” dialog. It appears to stem from the disabling of managed fields, as commenting that out prevents the issue (but also then doesn’t disable the fields, naturally)

My research led to me find that: “”When you disable a form field in JavaScript and the user attempts to leave the page, it can trigger the browser’s “Leave Site?” dialog. This is because the browser considers a disabled field as having unsaved changes.”

I’m not sure what would have changed from 6.5 -> 6.6 to cause the change. As the fields don’t appear filterable with PHP, I’m struggling to find an alternative solution to disabling managed fields that doesn’t trigger such an error when leaving the page.

2024-10-03 08_54_04-Profile ‹ WordPress Block Editor Support Site — WordPress

@MadtownLems
Copy link
Author

I believe the fix, since 6.6, is to set the fields to "readonly" instead of disabling them.

jQuery("' . $selectors . '").prop("readonly", true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant