Fix slider behavior when using navigate back button (#8496)

Closes https://github.com/FreshRSS/FreshRSS/issues/8488

* Ensure leave confirmation is shown by preventing navigation using the [Navigation API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API)
* Prevent scroll lock by removing it on `hashchange` instead of `onclick` on the close buttons
This commit is contained in:
Inverle
2026-02-08 20:42:20 +01:00
committed by GitHub
parent d7848e9fd6
commit 6b5304b825
2 changed files with 27 additions and 4 deletions

View File

@@ -362,6 +362,18 @@ function open_slider_listener(ev) {
f.insertAdjacentHTML('afterbegin', '<input type="hidden" name="slider" value="1" />');
});
context.ajax_loading = false;
window.addEventListener('hashchange', () => {
if (location.hash.substr(1) === 'slider') {
// Triggers when slider is closed
window.addEventListener('hashchange', () => {
location.hash = 'close';
slider.querySelectorAll('form').forEach(function (f) { f.reset(); });
document.documentElement.classList.remove('slider-active');
}, { once: true });
}
}, { once: true });
slider.dispatchEvent(freshrssSliderLoadEvent);
};
req.send();
@@ -384,8 +396,6 @@ function init_slider(slider) {
function close_slider_listener(ev) {
const slider = document.getElementById('slider');
if (data_leave_validation(slider) || confirm(context.i18n.confirm_exit_slider)) {
slider.querySelectorAll('form').forEach(function (f) { f.reset(); });
document.documentElement.classList.remove('slider-active');
return true;
}
if (ev) {