Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tauri-apps/meilisearch-docsearch
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5a76518fcd5c087f05624d355793af18c288347b
Choose a base ref
..
head repository: tauri-apps/meilisearch-docsearch
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ee3bb345ec2a131fac7753e7a9582c5fe9ed95a1
Choose a head ref
Showing with 29 additions and 8 deletions.
  1. +4 −0 CHANGELOG.md
  2. +2 −2 package.json
  3. +5 −5 pnpm-lock.yaml
  4. +13 −0 src/DocSearch.tsx
  5. +5 −1 src/DocSearchModal.tsx
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## \[0.7.0]

- [`549a4d8`](https://github.com/tauri-apps/meilisearch-docsearch/commit/549a4d852c7615c81b255bacc72cff51168775d0) ([#165](https://github.com/tauri-apps/meilisearch-docsearch/pull/165) by [@amrbashir](https://github.com/tauri-apps/meilisearch-docsearch/../../amrbashir)) Add `debounceDuration` option to set debouce duration or disable it.

## \[0.6.1]

- [`a20acbc`](https://github.com/tauri-apps/meilisearch-docsearch/commit/a20acbc1987c34a981652e572dd994fd905a1df2) Publish `index.bundled.esm.js` file which is an ESM bundled verion of the package.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meilisearch-docsearch",
"version": "0.6.1",
"version": "0.7.0",
"description": "A quick search component for meilisearch, inspired by algolia/docsearch.",
"license": "MIT or Apache-2.0",
"files": [
@@ -35,7 +35,7 @@
"format:check": "prettier --check \"./**/*.{js,jsx,ts,tsx,json,html,css}\" --ignore-path .gitignore"
},
"dependencies": {
"meilisearch": "0.44.1",
"meilisearch": "0.45.0",
"solid-js": "1.9.1"
},
"devDependencies": {
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/DocSearch.tsx
Original file line number Diff line number Diff line change
@@ -26,6 +26,19 @@ export interface DocSearchProps {
translations?: DocSearchTranslations;
searchParams?: SearchParams;
environment?: typeof window;
/**
* Duration to wait between keystores to determine whether a search should happen or not.
* Defaults to `200`.
*
* Set to `false` to disable debouncing.
*
* This is an optimization that discards unnecessary search operations, for example,
* if a user is typing `hello`, we skip search operations for `h`, `he`, `hel` and `hell`
* as this usually not what the user wants to search for, and instead wait a few milliseconds until
* the user stops typing for a brief moment, and then we do the search operation.
* In the previous example, that would be `hello`.
*/
debounceDuration?: number | false;
}

export type DocSearchTranslations = Partial<{
6 changes: 5 additions & 1 deletion src/DocSearchModal.tsx
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ export const DocSearchModal: Component<DocSearchModalProps> = ({
clientAgents,
searchParams,
environment = window,
debounceDuration = 200,
translations = {},
onClose,
initialQuery,
@@ -200,7 +201,10 @@ export const DocSearchModal: Component<DocSearchModalProps> = ({
setHitsCategories(catgeories);
});
}
const debouncedSearch = utils.debounce(search, 100);

const debouncedSearch = !debounceDuration
? search
: utils.debounce(search, debounceDuration);

if (initialQuery) {
onMount(() => {