Fixed #33156 -- Used sessionStorage to preserve quick filter for admin's navigation sidebar.

This commit is contained in:
Maxim Milovanov 2021-10-06 10:01:31 +03:00 committed by GitHub
parent 47f791f132
commit 1c802ca2a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -74,7 +74,7 @@
} else {
event.target.classList.add('no-results');
}
localStorage.setItem('django.admin.navSidebarFilterValue', filterValue);
sessionStorage.setItem('django.admin.navSidebarFilterValue', filterValue);
}
const nav = document.getElementById('nav-filter');
@ -82,7 +82,7 @@
nav.addEventListener('input', checkValue, false);
nav.addEventListener('keyup', checkValue, false);
const storedValue = localStorage.getItem('django.admin.navSidebarFilterValue');
const storedValue = sessionStorage.getItem('django.admin.navSidebarFilterValue');
if (storedValue) {
nav.value = storedValue;
checkValue({target: nav, key: ''});

View File

@ -167,7 +167,7 @@ class SeleniumTests(AdminSeleniumTestCase):
reverse('test_with_sidebar:auth_user_changelist')
)
filter_value_script = (
"return localStorage.getItem('django.admin.navSidebarFilterValue')"
"return sessionStorage.getItem('django.admin.navSidebarFilterValue')"
)
self.assertIsNone(self.selenium.execute_script(filter_value_script))
filter_input = self.selenium.find_element_by_css_selector('#nav-filter')