Overly general selector causes unwanted “Leave site?” popup
-
In Chrome, whenever I leave the Plugins page for my client’s site, I see the message:
“Leave site? Changes you made may not be saved.”
Similarly, in Firefox, this is the message:
This page is asking you to confirm that you want to leave — information you’ve entered may not be saved.
These are triggered by the “beforeunload” event handler in “wp-content/plugins/woo-variation-swatches/includes/getwooplugins/js/getwooplugins-settings.js”. Specifically, in this block of code:
// Edit prompt
$(function () {
var changed = false
$(':input:not(.no-track)').on('change', function () {
if (!changed) {
window.onbeforeunload = function () {
return params.i18n_nav_warning
}
changed = true
}
})
$('.submit :input').on('click', function () {
window.onbeforeunload = ''
})
})It appears to me that the first selector (‘:input:not(.no-track)’) may be too general. It appears to be triggered by something else on the page unintentionally. If I change this selector to ‘.submit :input:not(.no-track)’, to be more parallel to the selector below it, the problem goes away.
Would it be possible to make the first selector more specific so it isn’t triggered by items outside your code?
Thanks!
- You must be logged in to reply to this topic.