Skip to content

Create a flag emptyGetsAll #728

Closed as not planned
Closed as not planned

Description

@aworld1

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.

Activity

  1. jimmi-rbn commented on Aug 18, 2023

    @jimmi-rbn

    Love the product but this feature is must have.

  2. github-actions commented on Dec 17, 2023

    @github-actions

    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

  3. stephane-klein commented on Jan 10, 2024

    @stephane-klein

    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));
            }
        }
    
  4. github-actions commented on May 10, 2024

    @github-actions

    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

  5. added a commit that references this issue on Apr 2, 2026
    d33b735
  6. krisk commented on Apr 2, 2026

    @krisk
    Owner

    Fixed in d33b735. An empty (or whitespace-only) string query now returns all docs as FuseResult objects with item and refIndex. The limit option is respected. No new flag needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions