Fixing annoying bug, unable to go back to the article
after searching.
This commit is contained in:
parent
fcaa578afe
commit
f6c299d10b
@ -58,8 +58,10 @@ function startSuggestions() {
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
window.addEventListener('popstate', (event) => {
|
||||
console.log('refreshing');
|
||||
window.location.reload();
|
||||
if (event) {
|
||||
console.log('refreshing');
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
startSuggestions();
|
||||
let focusSearch = document.body.querySelector('nav.mobile-shortcuts div.search input');
|
||||
@ -246,8 +248,9 @@ function addListenersSearch() {
|
||||
const searchOverlay = document.querySelector('div.search-overlay');
|
||||
const searchInput = searchOverlay.querySelector('div.search input');
|
||||
fakeSearchInput.value = searchInput.value;
|
||||
const firstUrl = window.location.href;
|
||||
if (exitSearch !== null) {
|
||||
exitSearch.addEventListener('click', onExitSearch)
|
||||
exitSearch.addEventListener('click', (event) => { onExitSearch(event, firstUrl) })
|
||||
}
|
||||
const searchIconDesktop = document.querySelector('nav.desktop a.search-icon');
|
||||
if (searchIconDesktop !== null) {
|
||||
@ -457,11 +460,15 @@ function noResults(searchResults) {
|
||||
searchResults.appendChild(p)
|
||||
}
|
||||
|
||||
function onExitSearch() {
|
||||
function onExitSearch(event, firstUrl) {
|
||||
event.preventDefault();
|
||||
const searchOverlay = document.querySelector('div.search-overlay');
|
||||
if (searchOverlay !== null) {
|
||||
searchOverlay.classList.toggle('active');
|
||||
}
|
||||
if (!searchOverlay.classList.contains('active')) {
|
||||
history.pushState({}, '', firstUrl);
|
||||
}
|
||||
}
|
||||
|
||||
function onFakeSearchClick(e) {
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user