typesense / docusaurus-theme-search-typesense

A fork of the awesome @docusaurus/theme-search-algolia library customized to work with Typesense
https://typesense.org/docs/guide/docsearch.html
MIT License
67 stars 15 forks source link

Search bar results link and SearchPage don't load new results after first view #30

Open dtlhlbs opened 1 year ago

dtlhlbs commented 1 year ago

Description

When I use the search box for a second time it fails to reload the search.

Steps to reproduce

  1. Go to home
  2. Search for content using search bar
  3. Scroll to bottom results link
  4. Select results link and view all results
  5. Use the search bar for another term
  6. Scroll to bottom results link
  7. Select results link and view
  8. Repeat 5-7

Expected Behavior

New results will show for the new search terms

Actual Behavior

Old results from first search term continue to show

Metadata

Typesense Version: 0.9.0 (docusaurus-theme-search-typesense)

OS: Windows Chrome 109.0.5414.120 (Official Build) (64-bit) search-bug.webm

jasonbosco commented 1 year ago

@dtlhlbs I was able to replicate this issue in the Algolia search plugin that comes built-in with Docusaurus.

Since docusaurus-theme-search-typesense is a fork of the built-in Algolia plug-in, I think it would be more efficient to fix the issue in the built-in plugin and I can then pull those fixes into this fork.

Could you open an issue in the main docusaurus repo about this issue? (I was able to easily replicate this on docusaurus.com's search bar, which uses the Algolia plugin).

dtlhlbs commented 1 year ago

https://github.com/facebook/docusaurus/issues/8755

slorber commented 1 year ago

@jasonbosco FYI I totally removed the useSearchPage hook in https://github.com/facebook/docusaurus/pull/8757, in favor of 2 more specific hooks.

I made the 2 apis public in case you want to use them to simplify your plugin code. It's basically the same as the older useSearchPage but instead split in 2 distinct hooks with a more focused use-case.

import {useSearchLinkCreator,useSearchQueryString} from '@docusaurus/theme-common';

Will be backported for v2.4 unless you think it can be a problem for such third-party plugins (ping me in the PR in this case, I may miss replies here)