- Issue created by @marco.pagliarulo
When using facets checkbox widget, the checkbox status is wrongly changed when the user click because of the fix implemented for https://www.drupal.org/project/facets/issues/3210353 → .
The checkbox get checked for an invisible fraction of time, then unckecked by the window.onbeforeunload.
https://www.drupal.org/project/facets/issues/3210353 →
This creates a bad user interaction, additionally window.onbeforeunload do not actually solve any issue since the all checkbox do not works after clicking the back button. (All the JS is not reexecuted)
Click any checkbox and notice that it is unchecked until page reload. On clicking back, the checkbox status get updated as by expectation, however, no one checkbox then works.
The solution I am proposing is to use the even pageshow, that is executed after page load, but the event allow to check if the page is shown from the cache (e.persisted === true).
In this scenario, and when Drupal.facets is available. All the HTML created by JS (Checkbox + label) get removed and the behaviour reattached. This solution prevent the mishandling of the checkbox status on normal click, and fully restore the feature clicking the back button.
Active
2.0
Code