Skip to content

LocalStorageRecentSearchesPlugin not working with other hooks than onSubmit #1030

Open
@vrilcode

Description

@vrilcode

Description

You can’t use LocalStorageRecentSearchesPlugin with autocomplete option defaultActiveItemId (e.g. defaultActiveItemId: 0), because onSubmit lifecycle hook is not fired by autocomplete in this case. LocalStorageRecentSearchesPlugin is based on this hook. It would be good to have the choice, which lifecycle hooks trigger the plugin. In practice also onSelect is needed, but it’s currently only for querySuggestionsPlugin implemented:

if (source.sourceId === 'querySuggestionsPlugin' && inputValue) {

PS: It's unclear, whether incompatibility with defaultActiveItemId is intended behavior or a bug. At least it's very confusing and not mentioned anywhere in the docs.

Expected behavior

LocalStorageRecentSearchesPlugin should handle onSubmit and onSelect hook. At least, it should be mentioned in the docs, if it's not possible.

Environment

  • Autocomplete version: 1.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions