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

Create a flag emptyGetsAll #728

Closed
1 task done
aworld1 opened this issue Jul 18, 2023 · 4 comments
Closed
1 task done

Create a flag emptyGetsAll #728

aworld1 opened this issue Jul 18, 2023 · 4 comments

Comments

@aworld1
Copy link

aworld1 commented Jul 18, 2023

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Create an option that when the query is empty, instead of getting no results, all results are returned.

Desired solution

non-empty query: current behavior
emptyGetsAll is set to true: all results returned on empty input
emptyGetsAll is set to false: no results returned on empty input
default for flag should be false.

Alternatives considered

Hardcoding outside of library; ugly.

Additional context

The reason for this feature is if a search bar's behavior wants to get all entries on load when the query is empty (or when all characters are deleted), no hardcoded if-statement is necessary. Further, the items returned from Fuse.search are formatted differently than the list of objects fed as a parameter, as each object is placed as an "item" in the returned list. This improves consistency for the library and removes overhead.

@jimmi-rbn
Copy link

Love the product but this feature is must have.

Copy link

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 30 days

@github-actions github-actions bot added the Stale label Dec 17, 2023
@stephane-klein
Copy link

Workaround in my Svelte project:

    $: if (fuse) {
        if (searchInput == "") {
            graphNodesStore.set(fuse._docs); // <= to get all results
        } else {
            graphNodesStore.set(fuse.search(searchInput).map((row) => row.item));
        }
    }

@github-actions github-actions bot removed the Stale label Jan 11, 2024
Copy link

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 30 days

@github-actions github-actions bot added the Stale label May 10, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants