Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search.js example Bug results dont display when delete letter in word and retype #1856

Closed
Jieiku opened this issue May 12, 2022 · 3 comments
Closed
Labels
bug done in pr Already done in a PR

Comments

@Jieiku
Copy link
Contributor

Jieiku commented May 12, 2022

The primary Zola Themes site has this bug, and therefore nearly every theme created also has this bug. (because they use it as an example according to docs: https://www.getzola.org/documentation/content/search/)

To reproduce:

  • go here: https://www.getzola.org/themes/
  • Search for the term zola (good, results appear)
  • press backspace to delete the a from zola (good, results disappear)
  • Now type a again to form the word zola (BUG, no results)

Peek 2022-05-12 11-04

While designing I took the time to look at every single theme to not overlook any useful features, and one thing I noticed was that this bug did NOT exist for adidoks

Also while not necessarily a bug the search feature seems incomplete to not show the full results when pressing the "Enter Key" or the search icon. The only theme that I seen that did this and had a search icon/button was zolastrap

What I have done is extended the search functionality, to combine what these two scripts do, for the code from zolastrap I really only used the construct (function names, form actions), I rewrote the code so that it does this:

  • copy the contents of the suggestions popup box.
  • rename the suggestions popup box identifier from #suggestions to #results to allow me to style it slightly different.
  • add a header to the results page with the search term and a button to close the results.
  • display the contents into the main tag of the page.

Peek 2022-05-12 11-06

You can try it out here: https://abridge.netlify.app/

@Keats Keats added the bug label May 13, 2022
@Keats
Copy link
Collaborator

Keats commented May 13, 2022

That seems like a fairly simple JS bug, I'll have a look

@Jieiku
Copy link
Contributor Author

Jieiku commented May 18, 2022

Thank you! The only search.js that I could find that did not have this bug was the the Adidoks theme search.js

@Jieiku
Copy link
Contributor Author

Jieiku commented May 30, 2022

Update, I have improved the search.js used on Abridge Theme. My first creation of this script used inline javascript on the form action (When you press enter or the search icon to go to a results Page). I now use the onload event of the window to set the forms action directly from the search.js code instead of inline on the forms action.

The result is that I was able to enable Content Security Policy without setting unsafe-inline for the script src.

@Keats Keats added the done in pr Already done in a PR label Jun 10, 2022
@Keats Keats closed this as completed in 570e2fc Jul 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug done in pr Already done in a PR
Projects
None yet
Development

No branches or pull requests

2 participants